How to ProtoUI Template and MouseEvents for context menu

Hi,

I am trying to create a protoUI by combining Template and MouseEvents, like in this snippet: https://snippet.webix.com/75jsdwyp

I am doing so as to attach a context menu and be able to use the onBefore & onAfterContextMenu events. I know I can attach to the template’s $view, but I need the onBeforeContextMenu event in order to update the context menu before showing it. Getting click events would be a nice plus, too.

The problem is, that when I add the required onContext: {} to my protoUI template definition, I get a script error.

Is there an alternate way to achieve what I am trying to do?

Thank you.

https://snippet.webix.com/c6yvx495

Intregal,

Thank you for your reply. That snippet is a step in the right direction, but not quite what I meant.

I am trying to hook up this protoUI template component to a contextmenu component, like so: Code Snippet
There is no script error, but no contextmenu component shows either. I know if I make the master of the contextmenu the $$(‘body’).$view the contextmenu component shows, but that would not trigger the onBeforeContextMenu event I would like to attach to the template.

Thank you kindly.