Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Intercept mnemonic
Intercept mnemonic [message #1173139] Wed, 06 November 2013 05:09 Go to next message
Matthias Nick is currently offline Matthias Nick
Messages: 89
Registered: August 2013
Member
Hi,
I have got another question regarding mnemonics in RAP: In general they work fine, e.g. if the label is next to the textfield. However, I have a special case to consider:

+------------+ +------+ +------------------------------+
+  &Text     + +  *   + +                              +
+------------+ +------+ +------------------------------+
    Label       MLabel           TextField


Between the Label and the TextField is another label (MLabel) that means that when I press "alt+t", TextField will not get the focus. In SWT I have solved this problem by adding a new TraverseListener and waiting for SWT.TRAVERSE_MNEMONIC. However, I have seen that my TraverseListener is never called and RAP does not support SWT.TRAVERSE_MNEMONIC.

Do you guys see any way I can intercept the mnemonic hit and implement my own custom logic?

Thank you very much,
Matthias
Re: Intercept mnemonic [message #1181247 is a reply to message #1173139] Mon, 11 November 2013 08:26 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim Buschtoens
Messages: 355
Registered: July 2009
Senior Member
Hi.

I'm not sure what widget your "MLabel" is, but the best way I can think
of to get this working (assuming to use RAP 2.2) is to attach a FocusIn
ClientListener to that widget and focus the next widget in that Listener.

This might help:
http://eclipse.org/rap/developers-guide/devguide.php?topic=scripting.html&version=2.2#js-api

Here is an example for something similar (changing focus by typing):
http://git.eclipse.org/c/rap/incubator/org.eclipse.rap.incubator.clientscripting.git/tree/bundles/org.eclipse.rap.clientscripting.demo/src/org/eclipse/rap/clientscripting/demo/FocusSwitch.js

Note that you only need to register a key to attach the "next" widget to
once per UI session (WidgetUtil.registerDataKeys) and create the
ClientListener once per UI session. After that you only need to attach
the listener and "next" widget to each of your "MLabel" widgets.

Greetings,
Tim

Am 06.11.2013 11:09, schrieb Matthias Nick:
> Hi,
> I have got another question regarding mnemonics in RAP: In general they
> work fine, e.g. if the label is next to the textfield. However, I have a
> special case to consider:
>
>
> +------------+ +------+ +------------------------------+
> + &Text + + * + + +
> +------------+ +------+ +------------------------------+
> Label MLabel TextField
>
>
> Between the Label and the TextField is another label (MLabel) that means
> that when I press "alt+t", TextField will not get the focus. In SWT I
> have solved this problem by adding a new TraverseListener and waiting
> for SWT.TRAVERSE_MNEMONIC. However, I have seen that my TraverseListener
> is never called and RAP does not support SWT.TRAVERSE_MNEMONIC.
>
> Do you guys see any way I can intercept the mnemonic hit and implement
> my own custom logic?
>
> Thank you very much,
> Matthias

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Intercept mnemonic [message #1181349 is a reply to message #1181247] Mon, 11 November 2013 09:46 Go to previous messageGo to next message
Matthias Nick is currently offline Matthias Nick
Messages: 89
Registered: August 2013
Member
Hi Tim,
thanks for your answer.

MLabel is in fact a simple Label.

I tried the following in the Label's constructor:

  public Label( Composite parent, int style ) {
    super( parent, checkStyle( style ) );

    String js = "var handleEvent = function( event ) { window.alert(\"action\"); };";
    addListener(SWT.FocusIn, new ClientListener(js));
  }

However it won't be called if I hit the mnemonic - alt+t. Is it possible that a label does not support SWT.FocusIn?

Did I forget anything? (I also tried the above code with a Text, and there it works. So I assume the snippet is correct)

Thanks,
Matthias
Re: Intercept mnemonic [message #1182603 is a reply to message #1181349] Tue, 12 November 2013 04:39 Go to previous message
Tim Buschtoens is currently offline Tim Buschtoens
Messages: 355
Registered: July 2009
Senior Member
Hi.

> However it won't be called if I hit the mnemonic - alt+t. Is it possible
> that a label does not support SWT.FocusIn?

That is indeed possible. The Snippet looks good.
I guess the alternative would be to support SWT.TRAVERSE_MNEMONIC for
ClientListener, though that is a bit of work. I'm not sure yet that this
is manageable for the 2.2 release.

Greetings,
Tim


--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:How to set the different border width in theme css ?
Next Topic:Client Error "a is undefined" on asynchronous UI update
Goto Forum:
  


Current Time: Sat Apr 19 21:50:28 EDT 2014

Powered by FUDForum. Page generated in 0.01565 seconds