Reputation: 75
I need to implement widget that I can right click to disable it and right click to enable it again. My code is like this:
widget.sinkEvents(Event.ONCONTEXTMENU);
widget.addHandler(new ContextMenuHandler() {
@Override
public void onContextMenu(ContextMenuEvent event)
{
event.preventDefault();
event.stopPropagation();
if (widget.isEnabled()) widget.setEnabled(false);
else widget.setEnabled(true);
}
}, ContextMenuEvent.getType());
This works when the widget is enabled. Meaning I can right click to disable this widget. However, when the widget is disabled, it does not trigger the right click event.
Is there a way to make my custom right click working on a disabled widget?
Thanks,
Upvotes: 1
Views: 502
Reputation: 388
If the event doesn't fire on the disabled widget, you could try one of the following workarounds:
Upvotes: 1