Context Menu

I have been using ‘onBeforeContextMenu’ to listen for right click, launch a window, and return ‘false’ preventing context menu.

It works great on datatables and lists. But I want to be able to do the same off a template component. It does not seem to work.

Is there a different approach I could take with templates?

Template doesn’t have the onBeforeContextMenu. To attach Webix context menu or any action on the right click, you need to listen a native contextmenu event:

http://webix.com/snippet/f8b63e5e

This worked great actually.

FYI - for others who may come upon this, what ‘e’ returns is quite robust. I had no problem hooking in data to make this work.

There’s no built-in API for such cases. I can suggest only two ways:

a) Add a context menu only for the selected tab and get its ID via tabbar.getValue(): http://webix.com/snippet/2f67a97a

b) If you really want to attach menu for each tab, you can try to add a span that will fill the tab and contain a property which value will match the tab ID. Something like:

{ value: '<span . . . property="formView">Form</span>', id: 'formView'}

And then extract this value from e.target

Any advice on how to do this with tabbar tabs.

I want to be able to click on individual tab buttons and get standard functionality and right click on tab button to call contextmenu.

By their nature they seem to be rendered on click and when resizer is used. I have tried a number of different approaches but nothing is really working well.

For those who interested in the same solution, for now, it’s possible to use the context menu’s API to attach it to the tabbar.
As follows (comments are included): http://webix.com/snippet/766ea92c