123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
- XCOMM $XConsortium: EventHandlerTest.src /main/3 1996/04/23 20:18:10 drk $
- XCOMM #########################################################################
- XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
- XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
- XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
- XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
- XCOMM Novell, Inc.
- XCOMM #########################################################################
- XCOMM
- XCOMM This sample shell script demonstrates how event handlers can be added
- XCOMM and removed. It also demonstrates how the EH_WIDGET and EH_EVENT
- XCOMM convenience environment variables can be referenced.
- XCOMM
- EventHandler1()
- {
- echo "EH_WIDGET ="$EH_WIDGET
- echo "EH_EVENT ="$EH_EVENT
- echo "EH_EVENT.TYPE ="${EH_EVENT.TYPE}
- echo "event handler 1 invoked ("$1")"
- }
- EventHandler2()
- {
- echo "EH_WIDGET ="$EH_WIDGET
- echo "EH_EVENT ="$EH_EVENT
- echo "EH_EVENT.TYPE ="${EH_EVENT.TYPE}
- echo "event handler 1 invoked ("$1")"
- }
- XCOMM PushbuttonCallback: Adds an event handler to the form widget
- AddMaskableEventHandler1()
- {
- XtAddEventHandler $FORM2 "Button2MotionMask" False \
- "EventHandler1 1"
- }
- XCOMM PushbuttonCallback: Adds an event handler to the form widget
- AddMaskableEventHandler2()
- {
- XtAddEventHandler $FORM2 "ButtonPressMask|ButtonReleaseMask" False \
- "EventHandler1 1"
- }
- XCOMM PushbuttonCallback: Adds an event handler to the form widget
- AddMaskableEventHandler3()
- {
- XtAddEventHandler $FORM2 "Button2MotionMask" False \
- "EventHandler1 2"
- }
- XCOMM PushbuttonCallback: Adds an event handler to the form widget
- AddNonmaskableEventHandler()
- {
- XtAddEventHandler $FORM2 "NoEventMask" True "EventHandler2 1"
- }
- XCOMM PushbuttonCallback: Adds an event handler to the form widget.
- XCOMM Should report a bad event mask.
- AddBadEventHandler()
- {
- XtAddEventHandler $FORM2 "fooMask" False "EventHandler2 1"
- }
- XCOMM PushbuttonCallback: Removes an event handler to the form widget
- RemoveEventHandler1()
- {
- XtRemoveEventHandler $FORM2 "Button2MotionMask" False \
- "EventHandler1 1"
- }
- XCOMM PushbuttonCallback: Removes an event handler to the form widget
- RemoveEventHandler2()
- {
- XtRemoveEventHandler $FORM2 "ButtonPressMask|ButtonReleaseMask" False \
- "EventHandler1 1"
- }
- XCOMM PushbuttonCallback: Removes an event handler to the form widget
- RemoveEventHandler1and2()
- {
- XtRemoveEventHandler $FORM2 "XtAllEvents" True "EventHandler1 1"
- }
- XCOMM ###################### Create the Main UI ###############################
- XtInitialize TOPLEVEL eventHandlerTest EventHandlerTest "$0" "$@"
- XtCreateManagedWidget FORM form XmForm $TOPLEVEL
- XtCreateManagedWidget FORM2 form2 XmForm $FORM \
- topAttachment:ATTACH_FORM \
- leftAttachment:ATTACH_FORM \
- rightAttachment:ATTACH_FORM
- XtSetValues $FORM2 height:150 width:150
- XtCreateManagedWidget SEP sep XmSeparator $FORM \
- topAttachment:ATTACH_WIDGET \
- topWidget:$FORM2 \
- leftAttachment:ATTACH_FORM \
- rightAttachment:ATTACH_FORM
- XtCreateManagedWidget PB1 pb XmPushButton $FORM \
- labelString:"Add Maskable Event Handler 1" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$SEP \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:10 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:40
- XtAddCallback $PB1 activateCallback AddMaskableEventHandler1
- XtCreateManagedWidget PB2 pb2 XmPushButton $FORM \
- labelString:"Add Maskable Event Handler 2" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$SEP \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:60 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:90
- XtAddCallback $PB2 activateCallback AddMaskableEventHandler2
- XtCreateManagedWidget PB3 pb3 XmPushButton $FORM \
- labelString:"Add Maskable Event Handler 3" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB2 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:10 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:40
- XtAddCallback $PB3 activateCallback AddMaskableEventHandler3
- XtCreateManagedWidget PB4 pb4 XmPushButton $FORM \
- labelString:"Add Maskable Event Handler 4" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB2 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:60 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:90
- XtAddCallback $PB4 activateCallback AddMaskableEventHandler4
- XtSetSensitive $PB4 False
- XtCreateManagedWidget PB5 pb5 XmPushButton $FORM \
- labelString:"Add non-maskable Event Handler" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB4 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:10 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:40
- XtAddCallback $PB5 activateCallback AddNonmaskableEventHandler
- XtCreateManagedWidget PB6 pb6 XmPushButton $FORM \
- labelString:"Add Bad Event Handler" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB4 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:60 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:90
- XtAddCallback $PB6 activateCallback AddBadEventHandler
- XtCreateManagedWidget PB7 pb7 XmPushButton $FORM \
- labelString:"Remove Maskable Event Handler 1" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB6 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:10 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:40
- XtAddCallback $PB7 activateCallback RemoveEventHandler1
- XtCreateManagedWidget PB8 pb8 XmPushButton $FORM \
- labelString:"Remove Maskable Event Handler 2" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB6 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:60 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:90
- XtAddCallback $PB8 activateCallback RemoveEventHandler2
- XtCreateManagedWidget PB9 pb9 XmPushButton $FORM \
- labelString:"Remove Maskable Event Handler 1 and 2" \
- topAttachment:ATTACH_WIDGET \
- topWidget:$PB8 \
- topOffset:10 \
- leftAttachment:ATTACH_POSITION \
- leftPosition:10 \
- rightAttachment:ATTACH_POSITION \
- rightPosition:40 \
- bottomAttachment:ATTACH_FORM \
- bottomOffset:10
- XtAddCallback $PB9 activateCallback RemoveEventHandler1and2
- XtRealizeWidget $TOPLEVEL
- XtMainLoop
|