Disable standart PopupMenu
Posted: Sun Oct 26, 2025 4:42 am
How to disable pupupmenu standard in editorgadget()?
http://www.purebasic.com
https://www.purebasic.fr/english/
For which OS do you need this? The following example demonstrates how to disable the Popup menu on MacOS (successfully tested on MacOS 15.7.1 'Sequoia' with PB 6.21):
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_Version < 600
Import "-fno-pie" : EndImport
CompilerEndIf
ProcedureC RightClickCallback(Object.I, Selector.I, TextView.I, Menu.I,
Event.I, CharacterIndex.I)
Debug "Popup menu is diabled!"
ProcedureReturn 0
EndProcedure
Define AppDelegate.I = CocoaMessage(0, CocoaMessage(0, 0,
"NSApplication sharedApplication"), "delegate")
Define DelegateClass.I = CocoaMessage(0, AppDelegate, "class")
Define Selector.I = sel_registerName_("textView:menu:forEvent:atIndex:")
OpenWindow(0, 270, 100, 180, 80, "EditorGadget")
EditorGadget(0, 10, 10, 160, 60, #PB_Editor_WordWrap)
SetGadgetFont(0, LoadFont(0, "Monaco", 13))
SetGadgetText(0, "The quick brown fox jumps over the lazy dog.")
SetActiveGadget(0)
class_addMethod_(DelegateClass, Selector, @RightClickCallback(), "v@:@@@@")
CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow