wd is used to create the forms (windows and controls) in a user interface. The easiest way to do this is to use the Form Editor, which builds the appropriate
wd calls for you.
For a tutorial introduction to the Form Editor, see lab Form Editor.
The following example creates a window
mywin, adds a push button named
pressme, then shows it as a topmost window (i.e. it stays on top of any other window):
wd 'pc mywin;cc pressme button;pshow;ptop'
Once it is displayed, you can move the window away from the J session, so that you can see both the session and the window. You can set focus on the J session or in the window, by clicking on them.
If you now click on the button, it depresses, but otherwise nothing seems to happen. In fact, the click on the button causes an event. If a corresponding event handler is defined, then it is invoked, otherwise the event is ignored.
The following example is an event handler for the button. To try this out, enter the following definition:
mywin_pressme_button=: wdinfo bind 'button pressed'
Now when you click on the button, this event handler is run, and an information box pops up.
The event handler
mywin_pressme_button is an ordinary J verb. It was defined using the standard utility
wdinfo that displays an information message box, together with a specific argument '
button pressed'. For example, you can run this program from the J session, by entering: