Skip to Main Content
Volume 6A: Motif Programming Manual
book

Volume 6A: Motif Programming Manual

by David Brennan, Dan Heller, Paula Ferguson
September 1993
Intermediate to advanced content levelIntermediate to advanced
1014 pages
28h 26m
English
O'Reilly Media, Inc.
Content preview from Volume 6A: Motif Programming Manual
11.2.1 Handling Input Events
Since the callback approach to event handling is the simplest, we'll begin by discussing that approach. the source code
shows an extremely simple drawing program that associates a line drawing function with the XmNinputCallback
resource. Pressing any of the pointer buttons marks the starting point of a line; releasing the button marks the
endpoint. You can only draw straight lines. Even though the default translation table for the DrawingArea widget
selects key events and these events are passed to the callback function, the callback function itself ignores them and
thus key events have no effect.
To demonstrate the complications inherent in using the DrawingArea widget as a manager, the program also displays
a PushButton gadget that clears the window. A single callback function, drawing_area_callback(), uses both
the reason and the event fields of the XmDrawingAreaCallbackStruct to determine whether to draw a line
or to clear the window.
This simple application draws directly into the DrawingArea widget; the contents of its window is not saved
anywhere. The program does not support redrawing, since its purpose is strictly to demonstrate the way input handling
can be managed using the XmNinputCallback. If the window is exposed due to the movement of other windows,
the contents of the window is not redrawn. A more realistic drawing application would need code to handle both
expose and resize actions. The current application simply clears the window on resize to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Volume 7A: XView Programming Manual

Volume 7A: XView Programming Manual

Dan Heller

Publisher Resources

ISBN: 9780596000431