CallbackTest2.src 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: CallbackTest2.src /main/3 1996/04/23 20:17:57 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 widget callbacks can be
  12. XCOMM added and removed. It adds callbacks both using XtAddCallback and
  13. XCOMM by specifying a callback as a resource, when the test pushbutton
  14. XCOMM is created.
  15. XCOMM
  16. XCOMM The activate callback which can be dynamically added and removed
  17. ActivateCallback1()
  18. {
  19. echo "activateCallback1 invoked"
  20. }
  21. XCOMM The activate callback which is added when the widget was created
  22. ActivateCallback2()
  23. {
  24. echo "activateCallback2 invoked"
  25. }
  26. XCOMM Pushbutton Callback: Adds an activate callback to the test pushbutton
  27. AddCallback1()
  28. {
  29. XtAddCallback $TESTPB activateCallback ActivateCallback1
  30. XtGetValues $TESTPB activateCallback:AC
  31. echo "Callback list = "$AC
  32. }
  33. XCOMM Pushbutton Callback: Removes an activate callback from the test pushbutton
  34. DeleteCallback1()
  35. {
  36. XtRemoveCallback $TESTPB activateCallback ActivateCallback1
  37. XtGetValues $TESTPB activateCallback:AC2
  38. echo "Callback list = "$AC2
  39. }
  40. XCOMM ###################### Create the Main UI ###############################
  41. XtInitialize TOPLEVEL callbackTest CallbackTest "$0" "$@"
  42. XtCreateManagedWidget FORM form XmForm $TOPLEVEL
  43. XtCreateManagedWidget PB1 pb XmPushButton $FORM \
  44. labelString:"Add Callback1" \
  45. topAttachment:ATTACH_FORM \
  46. topOffset:10 \
  47. leftAttachment:ATTACH_POSITION \
  48. leftPosition:10 \
  49. rightAttachment:ATTACH_POSITION \
  50. rightPosition:40 \
  51. activateCallback:AddCallback1
  52. XtCreateManagedWidget PB2 pb2 XmPushButton $FORM \
  53. labelString:"Delete Callback1" \
  54. topAttachment:ATTACH_FORM \
  55. topOffset:10 \
  56. leftAttachment:ATTACH_POSITION \
  57. leftPosition:60 \
  58. rightAttachment:ATTACH_POSITION \
  59. rightPosition:90 \
  60. activateCallback:DeleteCallback1
  61. XtCreateManagedWidget TESTPB testpb XmPushButton $FORM \
  62. labelString:"Test Button" \
  63. topAttachment:ATTACH_WIDGET \
  64. topWidget:$PB2 \
  65. topOffset:20 \
  66. leftAttachment:ATTACH_POSITION \
  67. leftPosition:20 \
  68. rightAttachment:ATTACH_POSITION \
  69. rightPosition:80 \
  70. bottomAttachment:ATTACH_FORM \
  71. bottomOffset:10 \
  72. activateCallback:ActivateCallback2
  73. XtRealizeWidget $TOPLEVEL
  74. XtMainLoop