Calling menu from function

I want to display context menu only when its called from another js function. How can i do that? I have tried to create menu inside of function, but its does not work.

Hello
There is a method showContextMenu()
You need just to add the menu to a parent you need and show it via this method

Well it worked, thanks.

You are welcome!