Disable standart PopupMenu

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 203
Joined: Thu Dec 28, 2023 9:04 pm

Disable standart PopupMenu

Post by rndrei »

How to disable pupupmenu standard in editorgadget()?
Olli
Addict
Addict
Posts: 1272
Joined: Wed May 27, 2020 12:26 pm

Re: Disable standart PopupMenu

Post by Olli »

Few chances to do it natively.
User avatar
Shardik
Addict
Addict
Posts: 2074
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Disable standart PopupMenu

Post 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
Collection of cross-platform examples with API functions to extend PureBasic
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 203
Joined: Thu Dec 28, 2023 9:04 pm

Re: Disable standart PopupMenu

Post by rndrei »

Great, that's what you need!
Post Reply