Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Correct way to create hotkeys
icon5.gif  Correct way to create hotkeys [message #871219] Fri, 11 May 2012 13:27 Go to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Hello everyone.

I stumbled across this problem:
In a form that uses templates, I have a date field that I wish to be able to change with hotkeys - similar to the Up/Down keys already present when the field has focus.

But: It should work also when the component is not selected.
So I tried to add this:
    @Order(15.0)
    public class CTRL_H_Keystroke extends AbstractKeyStroke {

      @Override
      protected String getConfiguredKeyStroke() {
        return "f7";
      }

      @Override
      protected void execAction() throws ProcessingException {
        getDateField().setValue(DateUtility.getSysdate());
      }
    }


I actually wanted to give it the key CTRL-H, but that did not work.
So I used F7 which can't be really misspelled Wink

I tried to add this to the group box in which the field resides in, I tried to add it into the MainBox of the form, nothing.

Where should this be put to make it work? The wiki does not contain a lot about keystrokes.

TIA, Patrick

[Updated on: Fri, 11 May 2012 13:28]

Report message to a moderator

Re: Correct way to create hotkeys [message #871767 is a reply to message #871219] Mon, 14 May 2012 20:30 Go to previous messageGo to next message
Claudio Guglielmo is currently offline Claudio GuglielmoFriend
Messages: 256
Registered: March 2010
Senior Member
Hi Patrick

The action of the keystroke is only executed if the field containing the keystroke has the focus. So you can put it into a group box and if one field of that box has the focus the keystroke should work.

Which UI are you using? It seems that ctrl-h does not work with the swing ui, maybe it's used for something else? With the swt ui it works fine. shift-h seems to work for both.

If you are wondering whether your keystroke gets registered you could add a breakpoint in SwingScoutAction#attachScout

Btw: Global keystrokes are registered on the desktop. When creating a new scout project it should automatically add one, the refresh outline keystroke:

@Order(10.0)
public class RefreshOutlineKeyStroke extends AbstractKeyStroke {

  @Override
  protected String getConfiguredKeyStroke() {
    return "f5";
  }

  @Override
  protected void execAction() throws ProcessingException {
    if (getOutline() != null) {
      IPage page = getOutline().getActivePage();
      if (page != null) {
        page.reloadPage();
      }
    }
  }
}


Regards
Claudio
icon14.gif  Re: Correct way to create hotkeys [message #872434 is a reply to message #871767] Wed, 16 May 2012 05:50 Go to previous messageGo to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Thanks Claudio, that did the trick!

I use the Swing GUI and CTRL-H somehow seems to clear fields there.

So, using a different keystroke, putting it in the right groupbox (and into the concrete form, not into an abstract groupbox) it works for me now.

Thanks for your help.
Hotkeys using Scout NLS / ConfiguredText [message #892443 is a reply to message #871219] Thu, 28 June 2012 08:50 Go to previous messageGo to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Another hotkey-related question:

When setting a label on a button that contains an amperand (&), the following character will be the hotkey of that button.
This however does not work, if the button has the displaystyle DISPLAY_STYLE_LINK set.

Is it simply not possible for link buttons or does one have to do it differently there?

TIA,
Patrick
Re: Hotkeys using Scout NLS / ConfiguredText [message #893744 is a reply to message #892443] Thu, 05 July 2012 12:42 Go to previous messageGo to next message
Ken Lee is currently offline Ken LeeFriend
Messages: 97
Registered: March 2012
Member
Hi Patrick,

If you use an ampersand in your label, the character following the ampersand will be used as a so-called mnemonic.
Usually, a button in the Scout model is displayed as a JButton (Swing) or Button (SWT / RAP) in the UI.
However, buttons with the display style DISPLAY_STYLE_LINK are represented as JHyperlinks or Hyperlinks respectively. These UI components do not support mnemonics.

Have a look at the classes SwingScoutButton / SwingScoutLink (Swing), SwtScoutButton (SWT) and RwtScoutButton (RAP) in the method setLabelFromScout.
In case of SwingScoutLink you can see that the ampersand is removed from the label before the text is set.
In SwingScoutButton the character following the ampersand is set as a mnemonic.

I guess you have to provide a custom keystroke for your link button as Claudio described above. A potential disadvantage is that the hotkey is not obvious to the user.
Re: Hotkeys using Scout NLS / ConfiguredText [message #894344 is a reply to message #893744] Sun, 08 July 2012 13:59 Go to previous message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Hi Ken,

Thanks for your answer. Yes I thought that might be the case...
I'll have a look how a custom keystroke will work for this.

Regards, Patrick
Previous Topic:Smart field with master
Next Topic:Wizards howto?
Goto Forum:
  


Current Time: Fri Apr 19 23:18:57 GMT 2024

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

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

Back to the top