while trying to keep kernadec's Mandalas3D working smart on Linux too, I came across the problem that the menu or popupmenu is unavailable.
I could get to the bottom of the issue and found it is due to using ExamineKeyboard().
The following example shows the menu, popupmenu and an added keyboardshortcut working fine until ExamineKeyboard is enabled. Even creating that popupmenu within its own thread won't build it up.
Code: Select all
Enumeration
#Window0
#ListView
#PopMenu
#Button0
#Menu0
#Menu1
#Menu2
#popM
EndEnumeration
Procedure popme(pm)
If CreatePopupMenu(#PopMenu)
MenuItem(#Menu2, "List_____") : Debug "CreatePopup"
EndIf
DisplayPopupMenu(#PopMenu, WindowID(#Window0)) : Debug "DisplayPopup"
EndProcedure
InitSprite()
InitKeyboard()
Xs = 400 : Ys = 200
OpenWindow(#Window0, 0, 0, Xs, Ys, "CreateMenu + ExamineKeyboard", #PB_Window_SystemMenu | #PB_Window_WindowCentered | #PB_Window_ScreenCentered )
If CreateMenu(#Menu0, WindowID(#Window0))
MenuTitle("&Listview")
MenuItem(#Menu1, "Open&List" + Chr(9) + "Ctrl+O")
EndIf
; If CreateToolBar(#Menu0, WindowID(0)) ; the image will vanish, but the button stays valid
; ToolBarStandardButton(#Menu1, #PB_ToolBarIcon_Open)
; EndIf
AddKeyboardShortcut(#Window0,#PB_Shortcut_F2,#popM)
ButtonGadget(#Button0, 80, 0, 130, 25, "click me ... or F2")
OpenWindowedScreen(WindowID(#Window0), 0, 30, Xs, Ys, 0, 0, 0, #PB_Screen_SmartSynchronization)
Repeat
ClearScreen(0) : StartDrawing(ScreenOutput()) : DrawingMode(#PB_2DDrawing_Transparent)
For i = 1 To 13
DrawText(Random(300), Random(200), "Hello World!", RGB(Random(255), Random(255), Random(255)))
Next i
StopDrawing() : Delay(100) : FlipBuffers()
;; uncomment and the menu becomes unavailable:
; ExamineKeyboard()
; If KeyboardPushed(#PB_Key_P) :Debug "Key_P": popy = CreateThread(@popme(), 1) : WaitThread(popy): EndIf ;DisplayPopupMenu(#PopMenu, WindowID(#Window0),100,100) : EndIf
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Menu : Debug "case menu"
Select EventMenu()
Case #Menu1
Debug "#Menu1"
Case #popM
Debug "#popM" : popme(1)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #Button0 : Debug "#Button0": popy = CreateThread(@popme(), 1) : WaitThread(popy)
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
Until Event = #PB_Event_CloseWindow
;Until KeyboardPushed(#PB_Key_Escape)
EndGreets ~ Vera
