
Output of free_hand.c.
In the source code the DrawingArea widget uses the following translation string:
String translations =
"<Btn1Down>: draw(down) ManagerGadgetArm() 0 <Btn1Up>: draw(up) ManagerGadgetActivate() 0 <Btn1Motion>: draw(motion) ManagerGadgetButtonMotion()";
For each of the specified events, the translation describes two actions. The draw() action is our own function that
actually draws into the DrawingArea. The ManagerGadget actions are standard DrawingArea actions (inherited
from the Manager widget class) for passing events to a gadget child, as described earlier. We keep them in place
because we are still using the PushButton gadget. We are not keeping the routines for managing keyboard traversal,
but simply those required to arm and activate the button.
The draw() action routine tests whether it has been called from a button up event, a button down event, or a motion
event. Since the action function is passed the event that invoked it, we could simply test the type field of the event.
However, this example gives us a chance to exercise the Xt feature that supports string arguments passed to action
functions. Accordingly, the draw() function determines what action to take by examining its args[0] parameter,
which contains the string passed as the single parameter in the translation table. For example, draw(up) passes the
string "up" as the args[0] parameter in response to ...