Gmail-like keyboard shortcuts possible?

100 views
Skip to first unread message

Manuel

unread,
Jun 20, 2009, 12:23:29 PM6/20/09
to Google Web Toolkit
What's the best way to implement Gmail-like keyboard shortcuts?

I'd like to get all keypresses, except those in text boxes.

I've searched the archives, and I can't find a good way to do this.

Thanks,
Manuel

Thomas Broyer

unread,
Jun 21, 2009, 10:51:13 AM6/21/09
to Google Web Toolkit
Two solutions immediately come to mind:
1. create a widget and add a keypress handler (addDomHandler, this is
a protected method so you have to inherit an existing Widget subclass:
SimplePanel, AbsolutePanel, etc.); you should get events thanks to
bubbling, but not events directed to text boxes because they "eat"
them (stopPropagation)
2. preview events (Event.addNativePreviewHandler); here you'd get
events before they get to their target, including text boxes, so you'd
have to check that the actual target is not a text box.

Manuel

unread,
Jun 22, 2009, 5:56:05 PM6/22/09
to Google Web Toolkit
On Jun 21, 4:51 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 20 juin, 18:23, Manuel <msim...@gmail.com> wrote:
>
> > What's the best way to implementGmail-like keyboard shortcuts?
>
> > I'd like to get all keypresses, except those in text boxes.
%snip
> Two solutions immediately come to mind:
%snip
> 2. preview events (Event.addNativePreviewHandler); here you'd get
> events before they get to their target, including text boxes, so you'd
> have to check that the actual target is not a text box.

Thanks!

I use the second method, and actually text boxes consume the events,
so I don't even need to check for that.
Reply all
Reply to author
Forward
0 new messages