Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Setting Ctrl-+ as keystroke on a table
Setting Ctrl-+ as keystroke on a table [message #1403074] Mon, 21 July 2014 08:21 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I've tried to define keystrokes on a TableField to allow me to use it purely with the keyboard without using the mouse. This approach works in general.

However, I've been unable to assing the key combination "ctrl-+" to my keystroke. It is listed when I call getKeystrokes() on my table, but it seems that this key combination is hard wired into the table to auto resize the column widhts. Whenever I press "Ctrl" and the "+" key on the numpad, instead of calling my keystroke, the columns are resized.

Do I need a special key-string to reference the num_pad_+ key or is it just not possible to override this key combination?
Re: Setting Ctrl-+ as keystroke on a table [message #1403211 is a reply to message #1403074] Tue, 22 July 2014 11:27 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I have tried to use:

@Order(10.0)
public class PlusKeyStroke extends AbstractKeyStroke {

  @Override
  protected String getConfiguredKeyStroke() {
    return "CTRL-+";
  }

  @Override
  protected void execAction() throws ProcessingException {
    MessageBox.showOkMessage(null, "KeyStroke U", null);
  }
}


As far as I could debug:

I put a breakpoint in org.eclipse.scout.rt.ui.swt.keystroke.KeyStrokeManager.handleKeyEventHierarchical(Event, Widget)

When I press CTRL and "+"

I am on a Swiss-German Keyboard. The plus is located on the same key as "1". What I did press was CTRL + Shift + "Key 1"

* event.keyCode => 49 (ascii code for '1')
* event.stateMask => 393216 (means CTRL + Shift)
>>> (393216 & org.eclipse.swt.SWT.CTRL) != 0 is true
>>> (393216 & org.eclipse.swt.SWT.SHIFT) != 0 is true

When I press CTRL and "+" in the numpad

* event.keyCode => 16777259 (equals to SWT.KEYPAD_ADD)
* event.stateMask => 262144 (means CTRL)
>>> (262144 & org.eclipse.swt.SWT.CTRL) != 0 is true


In both cases it does not match the registered keystroke:

keyStroke.getKeyCode() => 43 (ascii code for '+')
keyStroke.getStateMask() => 262144

.
Re: Setting Ctrl-+ as keystroke on a table [message #1403213 is a reply to message #1403211] Tue, 22 July 2014 11:30 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I found how you can do it:
  @Override
  protected String getConfiguredKeyStroke() {
    return "CTRL-ADD";
  }


I found it by checking org.eclipse.scout.rt.ui.swt.util.SwtUtility.SCOUT_SWT_KEY_MAP with this line:
SCOUT_SWT_KEY_MAP.put("add", SWT.KEYPAD_ADD);

"add" seems to be the key to identify the '+' on the numpad.

.

[Updated on: Tue, 22 July 2014 11:32]

Report message to a moderator

Re: Setting Ctrl-+ as keystroke on a table [message #1403225 is a reply to message #1403213] Tue, 22 July 2014 13:08 Go to previous messageGo to next message
Matthias Nick is currently offline Matthias NickFriend
Messages: 197
Registered: August 2013
Senior Member
Hi,
we know that there are some problems with special keystrokes. See bug 422753
Re: Setting Ctrl-+ as keystroke on a table [message #1403233 is a reply to message #1403225] Tue, 22 July 2014 14:33 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I had a look at Bug 422753. I think the correct way to define a shortcut using the numeric keypad goes like this:

@Order(10.0)
public class NumPadPlusKeyStroke extends AbstractKeyStroke {

  @Override
  protected String getConfiguredKeyStroke() {
    return "CTRL-ADD";
  }

  @Override
  protected void execAction() throws ProcessingException {
    MessageBox.showOkMessage(null, getClass().getSimpleName(), null);
  }
}

@Order(20.0)
public class NumPadMinusKeyStroke extends AbstractKeyStroke {

  @Override
  protected String getConfiguredKeyStroke() {
    return "CTRL-SUBTRACT";
  }

  @Override
  protected void execAction() throws ProcessingException {
    MessageBox.showOkMessage(null, getClass().getSimpleName(), null);
  }
}

@Order(30.0)
public class NumPadSlashKeyStroke extends AbstractKeyStroke {

  @Override
  protected String getConfiguredKeyStroke() {
    return "CTRL-DIVIDE";
  }

  @Override
  protected void execAction() throws ProcessingException {
    MessageBox.showOkMessage(null, getClass().getSimpleName(), null);
  }
}

@Order(40.0)
public class NumPadMultiplyKeyStroke extends AbstractKeyStroke {

  @Override
  protected String getConfiguredKeyStroke() {
    return "CTRL-MULTIPLY";
    }

    @Override
    protected void execAction() throws ProcessingException {
      MessageBox.showOkMessage(null, getClass().getSimpleName(), null);
    }
  }
}


It works (with SWT and Swing).

We should document it on the KeyStroke wiki page.

.

[Updated on: Tue, 22 July 2014 14:34]

Report message to a moderator

Re: Setting Ctrl-+ as keystroke on a table [message #1403327 is a reply to message #1403233] Wed, 23 July 2014 03:38 Go to previous messageGo to next message
barust Mising name is currently offline barust Mising nameFriend
Messages: 57
Registered: February 2014
Member
When i testing KeyStroke I stumbled on this bug:
- In the project I used the swing, swt, rap.
- Setting Key Stroke like this:
http://i65.fastpic.ru/thumb/2014/0723/41/e2df37fdb38148e009ac63fa2cbc4841.jpeg

- with Swing shortcut (Ctrl-+) worked fine, but on SWT not worked.
- with RAP, when starting on browser appears next:
http://i67.fastpic.ru/thumb/2014/0723/dd/3af5dfe562bb15541680a3fb782d88dd.jpeg
Console shows that:
http://i68.fastpic.ru/thumb/2014/0723/eb/6f05d091fbc3dbe736599020bb0181eb.jpeg

I want to notice, this happens only with (Ctrl-+) shortcut.
Re: Setting Ctrl-+ as keystroke on a table [message #1403328 is a reply to message #1403327] Wed, 23 July 2014 04:01 Go to previous messageGo to next message
barust Mising name is currently offline barust Mising nameFriend
Messages: 57
Registered: February 2014
Member
Hurried with the question. Realy fine worked with (Ctrl-ADD) shortcut with Swing and SWT, but with RAP shortcuts (Ctrl-+) and (Ctrl--) zoom in and out page.
Re: Setting Ctrl-+ as keystroke on a table [message #1403339 is a reply to message #1403328] Wed, 23 July 2014 06:03 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Jérémie

Thanks for your answer, now my keystroke reacts to the numpad keys.

However when I press Ctrl-ADD, in addition to my own keystroke, the table still resizes its columns. This is something I do not want to happen. Is there any way to disable this behaviour?
Re: Setting Ctrl-+ as keystroke on a table [message #1403350 is a reply to message #1403339] Wed, 23 July 2014 07:12 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Urs Beeli wrote on Wed, 23 July 2014 08:03
However when I press Ctrl-ADD, in addition to my own keystroke, the table still resizes its columns. This is something I do not want to happen. Is there any way to disable this behaviour?


I didn't notice first, but I could reproduce it in my table.

From what I could debug, the org.eclipse.swt.widgets.TableColumn is sending a SWT.Resize event. I think it means that keys combination {"Ctrl", "Numpad +"} does some resizing. I am not sure you can influence it.

.
Re: Setting Ctrl-+ as keystroke on a table [message #1403480 is a reply to message #1403350] Thu, 24 July 2014 05:45 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks for your feedback.
Previous Topic:Decorating a boolean column with SWT
Next Topic:Page closing issue
Goto Forum:
  


Current Time: Thu Mar 28 23:12:03 GMT 2024

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

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

Back to the top