Right-Click-Selection-Update with open Context Menu [message #1830312] |
Thu, 23 July 2020 04:33  |
Eclipse User |
|
|
|
Hello everyone! I am trying to convince my NatTable to update the currently selected cell on a right click before opening the context menu, since the menu's content and actions are dependant on the selected cell.
In the general case, this can be accomplished by adding the following UiBindingConfiguration:
getNatTable().addConfiguration(new AbstractUiBindingConfiguration() {
@Override
public void configureUiBindings(UiBindingRegistry pUiBindingRegistry) {
pUiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, null, MouseEventMatcher.RIGHT_BUTTON),
new SelectCellAction());
}
});
However, this approach does not always work when the context menu is already open (i.e. by repeating right mouse clicks on an open table). My current best guess is that the statemask, specified as SWT.NONE, doesn't match in this specific case.
This theory is supported by the fact that holding down any control key(ctrl/alt/shift) while right clicking, which does mutate the statemask, also causes the selection to not update. If there was a way to register a MouseEventMatcher with no regard to the statemask, that may solve the issue. Alternatively, if the value of the statemask during my edge-case was known, i could register this edge-case and work around the issue that way.
The matter is made more complicated by the fact that the actual context menu is handled through the eclipse e4 framework, otherwise i could've just hardwired the Action for opening a context menu to do a SelectCellCommand first.
Any ideas?
[Updated on: Thu, 23 July 2020 05:09] by Moderator
|
|
|
|
|
Re: Right-Click-Selection-Update with open Context Menu [message #1830326 is a reply to message #1830320] |
Thu, 23 July 2020 07:59  |
Eclipse User |
|
|
|
Not sure if you are already aware, but context menus on NatTable where you need context information should NOT be added using the default Eclipse approach. You can of course configure your context menu like this, but the recommendation is to use the NatTable framework for context menus.
I wrote about the possibilities here: http://blog.vogella.com/2015/02/03/nattable-context-menus-with-eclipse-menus/
BTW, using your approach you probably break several NatTable functions or at least cause some side effects. I really recommend to get familiar with the NatTable framework before adding low level code without knowing the implications here. But of course this is only a recommendation.
For anyone else reading the suggested workaround: DON'T DO IT!
[Updated on: Thu, 23 July 2020 08:11] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.07753 seconds