- MacOS 10.6.8 'Snow Leopard'
- MacOS 10.12.3 'Sierra' (also tested with PB 5.44 x64 in ASCII and Unicode mode)
- Linux Mint 18 'Sarah' x86 Cinnamon with GTK2 and GTK3
- Lubuntu 14.04 x86 LXDE with GTK2 and GTK3
- PCLinuxOS 2014.05 MiniMe x86 KDE with GTK2 and GTK3
- Windows XP SP3
- Windows 7 SP1 x64 (also tested with PB 5.44 x64 in ASCII and Unicode mode)
- Windows 8.1 x64 (also tested with PB 5.44 x64 in ASCII and Unicode mode)
Unfortunately on Linux GTK2 and GTK3 seem to behave differently: using GTK3 you currently have to keep the right mouse button depressed and select the popup menu entry. Otherwise the popup menu will be closed when releasing the right mouse button...

Code: Select all
EnableExplicit
#Event_RightClick = #PB_Event_FirstCustomValue
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureC HyperLinkCallback(*Widget.GtkWidget,
*EventButton.GdkEventButton, UserData.I)
If *EventButton\button = 3
PostEvent(#Event_RightClick)
EndIf
EndProcedure
CompilerCase #PB_OS_MacOS
Define SubclassedHyperLink.I
ProcedureC HyperLinkCallback()
PostEvent(#Event_RightClick)
EndProcedure
CompilerCase #PB_OS_Windows
Define DefaultHyperLinkCallback.I
Procedure HyperLinkCallback(WindowHandle.I, Msg.I, WParam.I, LParam.I)
Shared DefaultHyperLinkCallback.I
If Msg = #WM_RBUTTONUP
PostEvent(#Event_RightClick)
EndIf
ProcedureReturn CallWindowProc_(DefaultHyperLinkCallback.I,
WindowHandle.I, Msg.I, WParam.I, LParam.I)
EndProcedure
CompilerEndSelect
OpenWindow(0, 270, 100, 220, 65, "HyperLinkGadget")
HyperLinkGadget(0, 70, 20, 74, 30, "HyperLink", $FF, #PB_HyperLink_Underline)
SetGadgetColor(0, #PB_Gadget_FrontColor, $FF0000)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
g_signal_connect_(gtk_widget_get_parent_(GadgetID(0)),
"button-press-event", @HyperLinkCallback(), 0)
CompilerCase #PB_OS_MacOS
SubclassedHyperLink = objc_allocateClassPair_(CocoaMessage(0,
GadgetID(0), "class"), "SubclassedHyperLink", 0)
object_setClass_(GadgetID(0), SubclassedHyperLink)
objc_registerClassPair_(SubclassedHyperLink)
class_addMethod_(SubclassedHyperLink,
sel_registerName_("rightMouseDown:"), @HyperLinkCallback(), "v@:@@")
CompilerCase #PB_OS_Windows
DefaultHyperLinkCallback.I = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC,
@HyperLinkCallback())
CompilerEndSelect
If CreatePopupMenu(0)
MenuItem(0, "Right click menu")
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #Event_RightClick
DisplayPopupMenu(0, WindowID(0))
EndSelect
ForEver