Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Table Right Mouse Click Event: execRowClick doesn't work( execRowClick doesn't work with MouseButton.Right)
Table Right Mouse Click Event: execRowClick doesn't work [message #1761226] Tue, 09 May 2017 08:40 Go to next message
Janosh Suter is currently offline Janosh SuterFriend
Messages: 5
Registered: April 2017
Junior Member
Hello everbody

in our application, we have a AbstractTable that has an "execRowClick(ITableRow row, MouseButton mouseButton)" event.

In this event I check if the clicked MouseButton was the MouseButton.Right.
Now, when I try to get into the Event with a LeftClick, it works without any Problems, but when I do that with a RightClick, it seems to doesn't trigger the execRowClick at all...

Is there any Solution or a workaround for this Problem?


Greets
Joshi
Re: Table Right Mouse Click Event: execRowClick doesn't work [message #1761353 is a reply to message #1761226] Wed, 10 May 2017 07:20 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 201
Registered: November 2010
Senior Member
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 #1761361 is a reply to message #1761353] Wed, 10 May 2017 08:08 Go to previous messageGo to next message
Janosh Suter is currently offline Janosh SuterFriend
Messages: 5
Registered: April 2017
Junior Member
Hi Beat, thank you for your quick response.

Our execRowClick method looks like this:

              @Override
              protected void execRowClick(ITableRow row, MouseButton mouseButton) throws ProcessingException {
                super.execRowClick(row, mouseButton);
                if (MouseButton.Right == mouseButton) {
                  removeOldKonfliktHandlingMenuItems();

                  if (!isGrundZugSelected()) {
                    addKonflikHandlingMenuItems(row);
                  }
                }
              }


What 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?


best regards,
Joshi
Re: Table Right Mouse Click Event: execRowClick doesn't work [message #1761378 is a reply to message #1761361] Wed, 10 May 2017 10:42 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 201
Registered: November 2010
Senior Member
Hi Joshi,

Janosh Suter wrote on Wed, 10 May 2017 04:08
What 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
Re: Table Right Mouse Click Event: execRowClick doesn't work [message #1761380 is a reply to message #1761378] Wed, 10 May 2017 11:44 Go to previous message
Janosh Suter is currently offline Janosh SuterFriend
Messages: 5
Registered: April 2017
Junior Member
Hi Beat,

The way with the execRowsSelected method works just fine for me. Smile

Thank you very much for your help!


best regards,
Joshi

Previous Topic:Re-visiting dynamic forms
Next Topic:Deploy Scout on Tomcat using the Tutorial
Goto Forum:
  


Current Time: Tue Mar 19 06:23:51 GMT 2024

Powered by FUDForum. Page generated in 0.02039 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top