|
Re: Table Right Mouse Click Event: execRowClick doesn't work [message #1761353 is a reply to message #1761226] |
Wed, 10 May 2017 07:20 |
|
Joshi,
By default, clicking the right mouse button on a table row opens the context menu. Apparently, the context menu handler consumes the event, so it will not bubble up to the handler that calls the execRowClicked method. Overriding this behavior is not directly supported.
Can you elaborate shortly on what your goal is? We usually don't bind the right mouse button to any important actions, because it would then not be available on touch devices such as tablets or smart phones. The opening of the context menu is just a shortcut for "power users".
If you really need to, you can try the following: Annotate your Table with a model variant: @ModelVariant("RightClick"). Then add your own JavaScript file RightClickTable.js and override the method "onContextMenu" to do nothing. (But I have not tested this, might have some unexpected effects!)
scout.RightClickTable = function() {
scout.RightClickTable.parent.call(this);
};
scout.inherits(scout.RightClickTable, scout.Table);
scout.RightClickTable.prototype.onContextMenu = function(event) {
// ignore event
};
Regards,
Beat
|
|
|
|
Re: Table Right Mouse Click Event: execRowClick doesn't work [message #1761378 is a reply to message #1761361] |
Wed, 10 May 2017 10:42 |
|
Hi Joshi,
Janosh Suter wrote on Wed, 10 May 2017 04:08What we like to do is, when the User clicks the right mouse button on a table row with conflict data, it should add some more specific MenuItems to choose from (addKonflikHandlingMenuItems()). If the row has no conflict Data, the specific MenuItems should be removed again.
So maybe there's a way to move this things in the context menu handler?
The "Scout way" would be to update the menus when the row selection changes, not when the mouse button is clicked. Because if you right click twice on the same row, the menus will still be the same. Only when you click a different row, the state might be different.
If the menus are totally dynamic (e.g. different number of menus for each row), then you could try to add your code to the table's execRowsSelected method.
If there is just one menu and you just want to have it visible or not depending on some row state, you statically program the menu and then override the method execOwnerValueChanged. Something like this:
public class ResolveConflictMenu extends AbstractMenu {
@Override
protected String getConfiguredText() {
return TEXTS.get("ResolveConflict");
}
@Override
protected Set<? extends IMenuType> getConfiguredMenuTypes() {
return CollectionUtility.hashSet(TableMenuType.SingleSelection, TableMenuType.MultiSelection);
}
@Override
protected void execOwnerValueChanged(Object newOwnerValue) {
boolean visible = false;
for (ITableRow row : getSelectedRows()) {
if (getHasConflictColumn() .getValue(row)) {
visible = true;
break;
}
}
setVisible(visible);
}
@Override
protected void execAction() {
for (ITableRow row : getSelectedRows()) {
resolveConflict(getKeyColumn().getValue(row));
}
}
}
Scout will automatically call "execOwnerValueChanged" when ever the row selection in the table is changed. The menu may then react to this individually, e.g. change the text or the visibility. This change is then automatically reflected in both the context menu and the menubar.
No custom JavaScript code or "right click" handling is required for this. Does this suit your purpose?
Regards,
Beat
|
|
|
|
Powered by
FUDForum. Page generated in 0.03884 seconds