jamirokwai wrote:WilliamL wrote:Would
this help?
No, but thanks for the hint.
The example crashes PB on OS X Lion.
I probably have to rewrite some portions and use an ImageGadget.
WilliamL should be right. His link to my example should work for you in Lion
if you change Procedure to Procedure
C...
Nevertheless I even customized your example to detect a right mouse button
click. Unfortunately I can't test it on Lion. And I won't upgrade to Lion as long
as Rosetta can't be installed in Lion to run old PowerPC programs...

:
Code: Select all
#kEventClassControl = 'cntl'
#kEventControlContextualMenuClick = 12
Structure EventTypeSpec
EventClass.L
EventKind.L
EndStructure
ProcedureC EventHandler(*NextEventHandler, Event.L, UserData.L)
Shared RightMouseButtonClick.I
RightMouseButtonClick = #True
If *NextEventHandler
CallNextEventHandler_(*NextEventHandler, Event)
EndIf
EndProcedure
Define RightMouseButtonClick.I
Dim EventTypes.EventTypeSpec(1)
OpenWindow(0,100,100,400,400,"TEST")
ButtonGadget(0,10,10,380,380,"CLICK ME!")
CreatePopupMenu(0)
MenuItem(1, "Option 1")
MenuItem(2, "Option 2")
MenuItem(3, "Quit")
; ----- Install EventHandler for each Gadget that should detect right clicks
EventTypes(0)\EventClass = #kEventClassControl
EventTypes(0)\EventKind = #kEventControlContextualMenuClick
InstallEventHandler_(GetControlEventTarget_(GadgetID(0)), NewEventHandlerUPP_(@EventHandler()), 1, @EventTypes(), GadgetID(0), 0)
Repeat
Event = WaitWindowEvent()
Gadget = EventGadget()
EventTyp = EventType()
Select Event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventTyp = #PB_EventType_LeftClick
Break
EndIf
Case #PB_Event_Menu
Select EventMenu()
Case 1
Debug "Menu: Option 1"
Case 2
Debug "Menu: Option 2"
Case 3
Break
EndSelect
EndSelect
If RightMouseButtonClick
DisplayPopupMenu(0, WindowID(0))
RightMouseButtonClick = #False
EndIf
ForEver