Friday, August 8, 2014

Re: keyboard shortcuts with CTRL

Hi Marcin,

We are using shortcut keys in our application. I have written the below code which uses CTRL+S. But there is an additional requirement that when the window is opened using the same CTRL+S the window should close. Is this possible. How do we do something like this.

    Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
      @Override
      public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
          NativeEvent ne = event.getNativeEvent();
          final int eventType = event.getTypeInt();
          boolean keyHandled = false;
          switch (eventType) {
              case Event.ONKEYDOWN:
                  if (ne.getCtrlKey()) {
                      switch (ne.getKeyCode()) {
                          case 's':
                          case 'S':
                            ne.preventDefault();
                            Scheduler.get().scheduleDeferred(new ScheduledCommand() {                             
                              @Override
                              public void execute() {
                                processSearchEvents(params);                               
                              }
                            });                           
                            break;
                      }
                  }
              }
  
        }
     });

Thanks,
Rahul

On Monday, October 4, 2010 7:44:05 PM UTC+5:30, Marcin Misiewicz wrote:
Here i post the solution.

Actually it's very easy :

                HandlerRegistration logHandler = Event.addNativePreviewHandler(new
NativePreviewHandler() {

                        @Override
                        public void onPreviewNativeEvent(NativePreviewEvent event) {
                                NativeEvent ne = event.getNativeEvent();
                                if (ne.getCtrlKey() && (ne.getKeyCode()=='l' ||
ne.getKeyCode()=='L')) {
                                        ne.preventDefault();
                                        DeferredCommand.addCommand(new Command() {

                                                @Override
                                                public void execute() {
                                                        loggerWindow.show();
                                                }
                                        });
                                }
                        }
                });

CTRL+l oraz CTRL+L - opens the window with log messages.

On 1 Paź, 00:35, Marcin Misiewicz <misq...@gmail.com> wrote:
> I'm also interested in that topic. Does anybody has some experience
> with keyboard shortcuts in gwt.
>
> I'd like to have at least one application wide shortcut for opening a
> log panel and a few shortcuts
> dependent of what panel actually has focus on.
>
> On 1 Wrz, 19:13, levier <levi.mail.l...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm developing an enterprise application and all users scream forkeyboardshortcuts.
> > And not shortcuts like you see in GMail (focus some widget, press c to
> > compose a new mail etc) but true CTRL+N, CTRL+S like you see in a
> > desktop application.
> > I thought it really couldn't be done, till I tried the google docs in
> > Chrome: CTRL+B made my text bold. Wow, that works! But probably it
> > only works on Chrome right, I thought, so I didn't really believe in
> > it and let it pass.
>
> > Then I saw Microsoft releasingkeyboardshortcuts in Hotmail. I tried
> > one and I got a pop up saying "hey you pressed some key, did you mean
> > it askeyboardshortcut?"... hahaha, so again I let it pass and
> > thought it couldn't be done.
> > But today I saw Microsoft releasing their Word, Excel... Office suite
> > on-line (search for Office Web Apps). I tried CTRL+B and it put my
> > text in bold and didn't show my Bookmarks bar instead! In IE8 and
> > Chrome.
>
> > Now, some proof that it doesn't really work all of the time: I
> > selected the text on the top of the page, hit CTRL+S and nothing
> > happens... there goes my belief in in-browserkeyboardshortcuts
> > again.
> > I guess thekeyboardlistener is only put on the textarea and ribbon
> > bar and not a "true browser window listener".
>
> > Still, my question stands:
> > how can I blockkeyboardshortcuts like CTR+O, CTRL+N and do something
> > with them instead of letting the browser handle them (CTRL+N typically
> > opens a new browser window, I don't want that)? Any advice is much
> > appreciated.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment