EventHandlerTest.src 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: EventHandlerTest.src /main/3 1996/04/23 20:18:10 drk $
  3. XCOMM #########################################################################
  4. XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
  5. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  6. XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  7. XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  8. XCOMM Novell, Inc.
  9. XCOMM #########################################################################
  10. XCOMM
  11. XCOMM This sample shell script demonstrates how event handlers can be added
  12. XCOMM and removed. It also demonstrates how the EH_WIDGET and EH_EVENT
  13. XCOMM convenience environment variables can be referenced.
  14. XCOMM
  15. EventHandler1()
  16. {
  17. echo "EH_WIDGET ="$EH_WIDGET
  18. echo "EH_EVENT ="$EH_EVENT
  19. echo "EH_EVENT.TYPE ="${EH_EVENT.TYPE}
  20. echo "event handler 1 invoked ("$1")"
  21. }
  22. EventHandler2()
  23. {
  24. echo "EH_WIDGET ="$EH_WIDGET
  25. echo "EH_EVENT ="$EH_EVENT
  26. echo "EH_EVENT.TYPE ="${EH_EVENT.TYPE}
  27. echo "event handler 1 invoked ("$1")"
  28. }
  29. XCOMM PushbuttonCallback: Adds an event handler to the form widget
  30. AddMaskableEventHandler1()
  31. {
  32. XtAddEventHandler $FORM2 "Button2MotionMask" False \
  33. "EventHandler1 1"
  34. }
  35. XCOMM PushbuttonCallback: Adds an event handler to the form widget
  36. AddMaskableEventHandler2()
  37. {
  38. XtAddEventHandler $FORM2 "ButtonPressMask|ButtonReleaseMask" False \
  39. "EventHandler1 1"
  40. }
  41. XCOMM PushbuttonCallback: Adds an event handler to the form widget
  42. AddMaskableEventHandler3()
  43. {
  44. XtAddEventHandler $FORM2 "Button2MotionMask" False \
  45. "EventHandler1 2"
  46. }
  47. XCOMM PushbuttonCallback: Adds an event handler to the form widget
  48. AddNonmaskableEventHandler()
  49. {
  50. XtAddEventHandler $FORM2 "NoEventMask" True "EventHandler2 1"
  51. }
  52. XCOMM PushbuttonCallback: Adds an event handler to the form widget.
  53. XCOMM Should report a bad event mask.
  54. AddBadEventHandler()
  55. {
  56. XtAddEventHandler $FORM2 "fooMask" False "EventHandler2 1"
  57. }
  58. XCOMM PushbuttonCallback: Removes an event handler to the form widget
  59. RemoveEventHandler1()
  60. {
  61. XtRemoveEventHandler $FORM2 "Button2MotionMask" False \
  62. "EventHandler1 1"
  63. }
  64. XCOMM PushbuttonCallback: Removes an event handler to the form widget
  65. RemoveEventHandler2()
  66. {
  67. XtRemoveEventHandler $FORM2 "ButtonPressMask|ButtonReleaseMask" False \
  68. "EventHandler1 1"
  69. }
  70. XCOMM PushbuttonCallback: Removes an event handler to the form widget
  71. RemoveEventHandler1and2()
  72. {
  73. XtRemoveEventHandler $FORM2 "XtAllEvents" True "EventHandler1 1"
  74. }
  75. XCOMM ###################### Create the Main UI ###############################
  76. XtInitialize TOPLEVEL eventHandlerTest EventHandlerTest "$0" "$@"
  77. XtCreateManagedWidget FORM form XmForm $TOPLEVEL
  78. XtCreateManagedWidget FORM2 form2 XmForm $FORM \
  79. topAttachment:ATTACH_FORM \
  80. leftAttachment:ATTACH_FORM \
  81. rightAttachment:ATTACH_FORM
  82. XtSetValues $FORM2 height:150 width:150
  83. XtCreateManagedWidget SEP sep XmSeparator $FORM \
  84. topAttachment:ATTACH_WIDGET \
  85. topWidget:$FORM2 \
  86. leftAttachment:ATTACH_FORM \
  87. rightAttachment:ATTACH_FORM
  88. XtCreateManagedWidget PB1 pb XmPushButton $FORM \
  89. labelString:"Add Maskable Event Handler 1" \
  90. topAttachment:ATTACH_WIDGET \
  91. topWidget:$SEP \
  92. topOffset:10 \
  93. leftAttachment:ATTACH_POSITION \
  94. leftPosition:10 \
  95. rightAttachment:ATTACH_POSITION \
  96. rightPosition:40
  97. XtAddCallback $PB1 activateCallback AddMaskableEventHandler1
  98. XtCreateManagedWidget PB2 pb2 XmPushButton $FORM \
  99. labelString:"Add Maskable Event Handler 2" \
  100. topAttachment:ATTACH_WIDGET \
  101. topWidget:$SEP \
  102. topOffset:10 \
  103. leftAttachment:ATTACH_POSITION \
  104. leftPosition:60 \
  105. rightAttachment:ATTACH_POSITION \
  106. rightPosition:90
  107. XtAddCallback $PB2 activateCallback AddMaskableEventHandler2
  108. XtCreateManagedWidget PB3 pb3 XmPushButton $FORM \
  109. labelString:"Add Maskable Event Handler 3" \
  110. topAttachment:ATTACH_WIDGET \
  111. topWidget:$PB2 \
  112. topOffset:10 \
  113. leftAttachment:ATTACH_POSITION \
  114. leftPosition:10 \
  115. rightAttachment:ATTACH_POSITION \
  116. rightPosition:40
  117. XtAddCallback $PB3 activateCallback AddMaskableEventHandler3
  118. XtCreateManagedWidget PB4 pb4 XmPushButton $FORM \
  119. labelString:"Add Maskable Event Handler 4" \
  120. topAttachment:ATTACH_WIDGET \
  121. topWidget:$PB2 \
  122. topOffset:10 \
  123. leftAttachment:ATTACH_POSITION \
  124. leftPosition:60 \
  125. rightAttachment:ATTACH_POSITION \
  126. rightPosition:90
  127. XtAddCallback $PB4 activateCallback AddMaskableEventHandler4
  128. XtSetSensitive $PB4 False
  129. XtCreateManagedWidget PB5 pb5 XmPushButton $FORM \
  130. labelString:"Add non-maskable Event Handler" \
  131. topAttachment:ATTACH_WIDGET \
  132. topWidget:$PB4 \
  133. topOffset:10 \
  134. leftAttachment:ATTACH_POSITION \
  135. leftPosition:10 \
  136. rightAttachment:ATTACH_POSITION \
  137. rightPosition:40
  138. XtAddCallback $PB5 activateCallback AddNonmaskableEventHandler
  139. XtCreateManagedWidget PB6 pb6 XmPushButton $FORM \
  140. labelString:"Add Bad Event Handler" \
  141. topAttachment:ATTACH_WIDGET \
  142. topWidget:$PB4 \
  143. topOffset:10 \
  144. leftAttachment:ATTACH_POSITION \
  145. leftPosition:60 \
  146. rightAttachment:ATTACH_POSITION \
  147. rightPosition:90
  148. XtAddCallback $PB6 activateCallback AddBadEventHandler
  149. XtCreateManagedWidget PB7 pb7 XmPushButton $FORM \
  150. labelString:"Remove Maskable Event Handler 1" \
  151. topAttachment:ATTACH_WIDGET \
  152. topWidget:$PB6 \
  153. topOffset:10 \
  154. leftAttachment:ATTACH_POSITION \
  155. leftPosition:10 \
  156. rightAttachment:ATTACH_POSITION \
  157. rightPosition:40
  158. XtAddCallback $PB7 activateCallback RemoveEventHandler1
  159. XtCreateManagedWidget PB8 pb8 XmPushButton $FORM \
  160. labelString:"Remove Maskable Event Handler 2" \
  161. topAttachment:ATTACH_WIDGET \
  162. topWidget:$PB6 \
  163. topOffset:10 \
  164. leftAttachment:ATTACH_POSITION \
  165. leftPosition:60 \
  166. rightAttachment:ATTACH_POSITION \
  167. rightPosition:90
  168. XtAddCallback $PB8 activateCallback RemoveEventHandler2
  169. XtCreateManagedWidget PB9 pb9 XmPushButton $FORM \
  170. labelString:"Remove Maskable Event Handler 1 and 2" \
  171. topAttachment:ATTACH_WIDGET \
  172. topWidget:$PB8 \
  173. topOffset:10 \
  174. leftAttachment:ATTACH_POSITION \
  175. leftPosition:10 \
  176. rightAttachment:ATTACH_POSITION \
  177. rightPosition:40 \
  178. bottomAttachment:ATTACH_FORM \
  179. bottomOffset:10
  180. XtAddCallback $PB9 activateCallback RemoveEventHandler1and2
  181. XtRealizeWidget $TOPLEVEL
  182. XtMainLoop