Problem solved :
The problem is that the PopUpWindowMenu does not send messages to the window until after the menu closes (under Windows at least). At which point all the buffered messages are sent to the window - one of which might be a menu action event.
I've changed the message loop to poll the message queue until it's empty.. this way it drops out once all the messages have been processed.
The problem is that the PopUpWindowMenu does not send messages to the window until after the menu closes (under Windows at least). At which point all the buffered messages are sent to the window - one of which might be a menu action event.
I've changed the message loop to poll the message queue until it's empty.. this way it drops out once all the messages have been processed.
Strict Graphics 640,480 While Not KeyDown(KEY_ESCAPE) Cls DrawText "Right mouse to invoke popup menu", 10,10 Flip If( MouseHit( 2 )) Local window:TGadget = CreateWindow("win", 0,0,10,10, Null, WINDOW_HIDDEN | WINDOW_MENU ) Local menu:TGadget = CreateMenu( "Menu", 0, WindowMenu( window )) CreateMenu( "Item 1", 1, menu ) CreateMenu( "Item 2", 2, menu ) CreateMenu( "Item 3", 3, menu ) CreateMenu( "Item 4", 4, menu ) PopupWindowMenu( window, menu ) Local nEvents = 0 While PollEvent() Select CurrentEvent.id Case EVENT_MENUACTION Select EventData() Case 1 DebugLog("Item 1 clicked") Case 2 DebugLog("Item 2 clicked") Case 3 DebugLog("Item 3 clicked") Case 4 DebugLog("Item 4 clicked") EndSelect EndSelect Wend FreeGadget( window ) FlushMouse() EndIf Wend