/* GUIBEGIN WINDOW , 53, 175, 241, 123, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Popup menu demo FONT 8, 400, MS Shell Dlg PUSH 9, 9, 40, 14, TABSTOP, , MyButton, , Push LIST 89, 7, 48, 40, NOTIFY|BORDER|VSCROLL|TABSTOP, , MyList DEND MENU Window HEADING &Window ITEM &Item 1 HEADING &Item 2 ITEM Subitem 1 ITEM SubItem 2 < < DEND MENU Button HEADING &Button ITEM &Item 1 ITEM &Item 2 < DEND MENU List HEADING &List ITEM &Item 1 ITEM &Item 2 < DEND GUIEND */ OPTIONS "C_CALL LABELCHECK NOSOURCE" /* This script demonstrates adding a CONTEXTMENU event handler for our window. * This event happens when the user clicks the right mouse button while the * pointer is inside our window, or some control inside our window. Typically, * this is used to present a popup menu pertinent to the window or control. * Our example window has two controls -- a button and a list box. We define * 3 menus, and name the definitions "Window", "Button", and "List". (You can * choose any names you prefer). When the user right-clicks on our button control, * we'll call GuiMenuAdd to popup the "Button" menu. When the user right-clicks * on our list control, we'll call GuiMenuAdd to popup the "List" menu. And when * the user right-clicks on our window, we'll call GuiMenuAdd to popup the * "Window" menu. * * And just for illustration, we've added event handlers for all the menu items * in these menus. The event handler simply presents a message box stating what * menu and item was selected. * * NOTE: A popup menu can have only one heading. But it may have as many items * and sub-items as you like. */ LIBRARY rexxgui GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION('M') SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN /* Called by Reginald when the user clicks the right mouse button * over our window (or perhaps some control in the window). */ WM_CONTEXTMENU: /* ARG(1) is a handle to our window if he clicked on that. * Otherwise, it is the handle to some control he clicked * upon. */ /* Did he click on our window itself? */ IF GuiWindow == ARG(1) THEN /* Present our popup menu named "Window" at the position * where the user clicked in the window. */ GuiAddMenu("Window") /* He clicked on one of our controls. */ ELSE DO /* First let's get the REXX variable associated with the control handle. NOTE: * The returned variable name is upper-cased. */ variable = GuiInfo("VARIABLE", ARG(1)) /* Now figure out which menu to popup. */ SELECT variable /* If it was "MyButton" control, present our "Button" popup menu. */ WHEN "MYBUTTON" THEN GuiAddMenu("Button") /* If it was "MyList" control, present our "List" popup menu. */ WHEN "MYLIST" THEN GuiAddMenu("List") /* Let the OS handle any context menu for other controls. */ OTHERWISE RETURN "" END END /* Don't let Rexx Gui process this event. */ RETURN "" /* Event handlers for all the menu items. */ WindowItem1: GuiSay('"Window -> Item 1" was selected') RETURN WindowItem2Subitem1: GuiSay('"Window -> Item 2 -> Sub Item 1" was selected') RETURN WindowItem2SubItem2: GuiSay('"Window -> Item 2 -> Sub Item 2" was selected') RETURN ButtonItem1: GuiSay('"Button -> Item 1" was selected') RETURN ButtonItem2: GuiSay('"Button -> Item 2" was selected') RETURN ListItem1: GuiSay('"List -> Item 1" was selected') RETURN ListItem2: GuiSay('"List -> Item 2" was selected') RETURN