PopupTest.src 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: PopupTest.src /main/3 1996/04/23 20:18:36 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 the steps necessary to create and
  12. XCOMM manage a popup menu.
  13. XCOMM
  14. XCOMM This event handler positions the menu at the point where the button event
  15. XCOMM occurred, and then posts the popup menu.
  16. EventHandler()
  17. {
  18. XmMenuPosition $POPUP $EH_EVENT
  19. XtManageChild $POPUP
  20. }
  21. XCOMM Menu button callback
  22. MenuActivated()
  23. {
  24. echo "Menu Activated: "$1
  25. }
  26. XCOMM ###################### Create the Main UI ###############################
  27. XtInitialize TOPLEVEL popupTest PopupTest "$0" "$@"
  28. XtCreateManagedWidget FORM form XmForm $TOPLEVEL
  29. XtSetValues $FORM height:300 width:300
  30. XtAddEventHandler $FORM "ButtonPressMask" False EventHandler
  31. XmCreatePopupMenu POPUP $FORM "popup"
  32. XmCreatePushButton PB1 $POPUP "pb1" \
  33. labelString:"Menu Item 1"
  34. XtManageChild $PB1
  35. XtAddCallback $PB1 activateCallback "MenuActivated MenuItem1"
  36. XmCreatePushButton PB2 $POPUP "pb2" \
  37. labelString:"Menu Item 2"
  38. XtManageChild $PB2
  39. XtAddCallback $PB2 activateCallback "MenuActivated MenuItem2"
  40. XtRealizeWidget $TOPLEVEL
  41. XtMainLoop