How can I connect methods to the media field right click context menu?
[attachment=0]2014-01-24_12_01_53-Servoy_smart_client_mediafield_context_menu.png[/attachment]
How can I connect methods to the media field right click context menu?
[attachment=0]2014-01-24_12_01_53-Servoy_smart_client_mediafield_context_menu.png[/attachment]
you can’t when the field is editable.
If you put it in a non-editable state, you can probably do this.
Then you’ll also need to code the rest of the stuff you want to do with this field…
mboegem:
you can’t when the field is editable.
If you put it in a non-editable state, you can probably do this.
I only get the context menu in the frameworks edit mode.
mboegem:
Then you’ll also need to code the rest of the stuff you want to do with this field…
I already have the functions that I want to bind to appropriate context menu entries.
deezzub:
I only get the context menu in the frameworks edit mode.
That’s correct, but these are the default options which you can’t alter.
When you put the field in a non-editable state, you can attach a method to the right-click property of the field.
In order to show a popup menu, you have to use the window plugin.
var _oSource = event.getSource();
var _oMenu = plugins.window.createPopupMenu(), _oSubmenu, _oItem;
_oItem = _oMenu.addMenuItem('My First Option',myCallbackMethod);
_oItem.enabled = true;
_oItem.methodArguments = [arg1, arg2];
_oMenu.addSeparator();
_oItem = _oMenu.addMenuItem('My Second Option', myCallbackMethod);
_oItem.enabled = true;
_oItem.methodArguments = [arg1, arg3];
_oMenu.show(_oSource);
mboegem:
… which you can’t alter.
Why?
mboegem:
When you put the field in a non-editable state, you can attach a method to the right-click property of the field.
In order to show a popup menu, you have to use the window plugin.var _oSource = event.getSource();
var _oMenu = plugins.window.createPopupMenu(), _oSubmenu, _oItem;
_oItem = _oMenu.addMenuItem('My First Option',myCallbackMethod);
_oItem.enabled = true;
_oItem.methodArguments = [arg1, arg2];
_oMenu.addSeparator();
_oItem = _oMenu.addMenuItem('My Second Option', myCallbackMethod);
_oItem.enabled = true;
_oItem.methodArguments = [arg1, arg3];
_oMenu.show(_oSource);
Some of the context menu entries, I only need in edit mode. For example, it is only allowed in edit mode to upload a media.
deezzub:
mboegem wrote:
… which you can’t alter.Why?
It’s part of the field type.
deezzub:
Some of the context menu entries, I only need in edit mode. For example, it is only allowed in edit mode to upload a media.
That’s why there’s a property ‘enabled’ on each item.
You can set that based on your own conditions.
Another option is to leave the item out base on the conditions.