Catch right mouse click in a control

I have a control that inherits from IBSwitchControl. In my OnMouseDown() I try to catch a mouse right click with if(mod.R) but it does not work. I can catch a left mouse click with if(mod.L).

Any ideas? Someone?

Try to:
#define IGRAPHICS_NO_CONTEXT_MENU
But remember that you’ll lose some plug format and host dependent right click compatibility.

Aha! Thanks. It is a context menu I am trying to create. So I guess I should dig in on how to use the API for that.

The define prevents the right click capture in OnMouseDown() in IGraphics.cpp if an IControl is associated to a ParamIdx. You can find some further ContextMenu info in IControl.h:

virtual void CreateContextMenu(IPopupMenu& contextMenu)

  /** Called by default when the user right clicks a control.
If IGRAPHICS_NO_CONTEXT_MENU is enabled as a preprocessor macro right clicking control will mean IControl::CreateContextMenu()
and IControl::OnContextSelection() do not function on right clicking control.
VST3 provides contextual menu support which is hard wired to right click controls by default.
You can add custom items to the menu by implementing IControl::CreateContextMenu() and handle them in IControl::OnContextSelection().
In non-VST 3 hosts right clicking will still create the menu, but it will not feature entries added by the host. */

Thanks!

With the methods:

  void CreateContextMenu(IPopupMenu& contextMenu) override;
  void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx) override;
  void OnContextSelection(int itemSelected) override;

I could create what I wanted.

I discovered that the context menu works fine in standalone and as vst3 but it doesn’t work in WAM.

1 Like