I was playing around with the SysTray-Thing on Mac OS X. Looks really promising. However, I fell into a little trap...
The following code opens a window, sets up the SysTrayIcon and a Menu, and waits for the user to click. There are two options in the Menu. Works as expected.
If you bring Finder to front and click again on the SysTrayIcon, the Menu appears. But when selecting a line with left mouse button, the #PB_Event_Menu-part won't be executed. As you can see, I added BringToFront_ and SetActiveWindow, which didn't do the trick
Any ideas?
Code: Select all
OpenWindow(0,50,50,50,50,"systraytest")
CreatePopupMenu(0)
MenuItem(1,"Test")
MenuItem(2,"Quit")
CreateImage(0,40,16,32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaChannel|#PB_2DDrawing_Transparent)
Box(0, 0, 40, 16, RGBA(0,0,0,0))
DrawText(1,1,"TEST",RGBA(0,0,0,255))
StopDrawing()
AddSysTrayIcon (0, WindowID(0), ImageID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_SysTray
Select EventType()
Case #PB_EventType_LeftClick
; this won't help
; BringToFront_(WindowID(0))
; SetActiveWindow(0)
DisplayPopupMenu(0, WindowID(0))
EndSelect
; this won't be executed, when the program is set to background
Case #PB_Event_Menu
Select EventMenu()
Case 1 : MessageRequester("!", "works")
Case 2 : Exit = 1
EndSelect
EndSelect
Until Exit = 1
