How to REMOVE the "Services" menu from contextual menus?

By default it seems contextual menus include the Mac “Services” on the first invocation, and subsequent invocations of the same contextual menu do not show services. How do I remove the services menu altogether? That is, make my menu’s NEVER show the services menu?

it depends if you return true or false from the constructcontextualmenu event

I have the same query. I’ve tried adding Return True and Return False at the end of the code in my ContextualMenuAction event, but it doesn’t seem to make any difference - the Services option is still there at the bottom of the contextual menu.

Phillip,

As Jean states, you will want to do that in the constructor ConstructContextualMenu

Thanks, Brian. I will try that.

Odd, I never see the Services menu in any of my contextual menus under macOS.

I’m still seeing it, even after trying Return False and Return True in the ConstructContextualMenu event (one then then other, not both together).
I’m basically using the example code given in the documentation for ConstructContextualMenu event for TextArea. Right-clicking on a word in the TextArea brings up the contextual menu with ‘Test 1’ as the menu item, but whatever I try to remove it, I’m still getting the Services many item and the full sub-items appearing beneath Test 1.
It’s not a massive pain, but it just seems there is a way to stop Services coming up and I’m missing it.

Well, here’s one of my ConstructContextualMenu event handlers copied verbatim from my app:

[code]// Construct the contextual menu for the button bar.

Var itemPtr as MenuItem

itemPtr = new MenuItem (“Manage Buttons”)
base.AddMenu (itemPtr)

return True
[/code]

It produces a contextual menu with just the one item. I’m using 2019r3.1, and this is under macOS 10.14.6.

Thanks, Tim, I appreciate your efforts. However, even using your code, I still get Services as the final menu item (with all its usual sub-items).
I’ll ponder on this further. It’s not the most pressing item on my To Be Coded list :slight_smile:

[quote=490508:@Philip Ling]Thanks, Tim, I appreciate your efforts. However, even using your code, I still get Services as the final menu item (with all its usual sub-items).
I’ll ponder on this further. It’s not the most pressing item on my To Be Coded list :-)[/quote]

Meanwhile, I’m completely hornswoggled.

this is “normal” behavior". the textarea contextual menu is handled by the operating system
you can only construct a menu in the window or in another control item, but not a textarea.

Remove the two contextualmenus events and add a mousedown event in the textarea:

[code]Function MouseDown(X As Integer, Y As Integer) Handles MouseDown as Boolean
if IsContextualClick then
dim base as new MenuItem
//construct your menuitem list

dim results as MenuItem
results = base.PopUp
if results <> nil then
 //do the job
end if
Return true

end if

#Pragma Unused x
#Pragma Unused y
End Function[/code]