Page 1 of 1

Disable standart PopupMenu

Posted: Sun Oct 26, 2025 4:42 am
by rndrei
How to disable pupupmenu standard in editorgadget()?

Re: Disable standart PopupMenu

Posted: Sun Oct 26, 2025 9:17 am
by Olli
Few chances to do it natively.

Re: Disable standart PopupMenu

Posted: Sun Oct 26, 2025 11:00 am
by Shardik
rndrei wrote: Sun Oct 26, 2025 4:42 am How to disable pupupmenu standard in editorgadget()?
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

Re: Disable standart PopupMenu

Posted: Sun Oct 26, 2025 12:43 pm
by rndrei
Great, that's what you need!