Dear Andre,
you're right. This is a wrong example in the sense to sign it as
'Supported OS: All'. It doesn't work on Linux either.
As for the mouse click events - there are 4 PB constants, they only needed to be assigned for the WindowEvent as well.
(Maybe this should be a feature request ?)
#PB_EventType_LeftClick
#PB_EventType_LeftDoubleClick
#PB_EventType_RightClick
#PB_EventType_RightDoubleClick
To show how the popup-menu works does not need to dependent on the
'WindowEvent'. Here are two alternatives:
Code: Select all
If OpenWindow(0, 200, 200, 200, 120, "Popup-Menu Example")
CreateImage(0, 200, 120)
ImageGadget(0, 0, 0, 200, 120, ImageID(0))
If CreatePopupMenu(0) ; hier beginnt das Erstellen des Popup-Menüs...
MenuItem(3, "Save as")
MenuItem(4, "Quit")
EndIf
Repeat
Select WaitWindowEvent() ; überprüfe Window-Ereignisse
Case #PB_Event_Gadget ; rechte Maustaste wurde gedrückt =>
If EventType() = #PB_EventType_RightClick
DisplayPopupMenu(0, WindowID(0)) ; stelle jetzt das Popup-Menü dar
EndIf
Case #PB_Event_Menu ; ein Eintrag des Popup-Menüs wurde angeklickt
Select EventMenu() ; ermittle den angeklickten Menü-Eintrag...
Case 3 : Debug "Menu: Save as"
Case 4 : Quit = 1
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
Code: Select all
If OpenWindow(0, 100, 100, 300, 100, "Popup-Menu Example 2")
ButtonGadget(0, 130, 25, 100, 30, "PopupMenu")
If CreateMenu(1, WindowID(0))
MenuTitle("Menu-1")
MenuItem(1, "Tab 1" +Chr(9) + "A")
MenuItem(3, "Tab 3" +Chr(9)+"Ctrl+B")
MenuItem(5, "Tab 5" +Chr(9)+"Cmd+C") ; used on MAC
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 0
CreatePopupImageMenu(0)
MenuItem(0, "Item 1" + Chr(9) + "A")
MenuItem(0, "Item 2" + Chr(9) + "Ctrl+B")
MenuItem(0, "Item 3" + Chr(9) + "Cmd+C") ; used on MAC
DisplayPopupMenu(0, WindowID(0))
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
(also works on MAC, verified by WilliamL ~ thanks)
regards ~ Vera
Addendum: as the second example is more an empty static structure I've made a more extensive one rounded with operable event commands and posted it in
Using PopUpMenus.