92 CHAPTER 7. GRAPHICAL USER INTERFACE DESIGN IN SCHEME
(define w (window "test"
(col
(label "enter a number and hit return to double
(t "x" (textfield "1" 20))
(button "double" (action (lambda(e)
(let ((val (readexpr (t "x"))))
(writeexpr (t "x") (* 2 val))))))))))
(.pack w) (.show w)
Figure 7.2: A simple example of tagging and actions
(t "abc" X)
to lookup the object whose name is  abc , you use the syntax
(t "abc")
For example, the program in Figure 7.2 shows the standard way of creating a
textfield with an associated action that reads and writes data onto the textfield
when a button is pushed.
7.14
Actions
One of the most important arguments to components is the  action  argument
which specifies what to do when the component is selected (e.g. when a button is
pushed or a menuitem selected, or a choice selected, or a textfield value entered).
The syntax for the action argument is:
(action (lambda (e) COMMANDS))
the  lambda  specifies that the  COMMANDS  are to be delayed until the
action is performed. The  e  represent the kind of event that triggered the
action. From the  e  variable we can get the time the action was triggered,
which component it came from, where the mouse was (for a mouse event), etc.
7.15
Reading and Writing on Components
The most common actions associated to simple GUIs involve reading some val 
ues entered or selected by the user, and using those values to compute some
quantity that is then written onto another component. Thus we need to have a
mechanism for reading and writing Scheme components. These procedures are
shown below:
  (readstring COMPONENT)   reads the text on a component as a string
  (readexpr COMPONENT)   reads the text on a component as a Scheme
term




  

Home

About Services Network Support FAQ Order Contact
 

Tomcat Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved