how to catch the double click event

7 views
Skip to first unread message

arun

unread,
Feb 4, 2009, 2:14:52 AM2/4/09
to Google Web Toolkit
i have a requirement to catch the double click event. i am catching
right click too. but both event are getting mixed up. only right click
is working fine. Thsi may be because both event have same constant
field values. is ther eany way to distinguish these two?
Any help would be appreciated.

Litty Preeth

unread,
Feb 4, 2009, 2:38:35 AM2/4/09
to Google-We...@googlegroups.com
No the constants for both are different... Event.ONCLICK and Event.ONDBLCLICK

arun

unread,
Feb 4, 2009, 3:08:43 AM2/4/09
to Google Web Toolkit
no...actually i m mentioning about event.BUTTON_RIGHT and
event.ONDBLCLICK
Both having same value i.e.2 and i m using both in my application.
> > Any help would be appreciated.- Hide quoted text -
>
> - Show quoted text -

Jason Morris

unread,
Feb 4, 2009, 3:22:48 AM2/4/09
to Google-We...@googlegroups.com
It doesn't matter that they have the same value, they are returned from 2 different fields in Event:

if(event.getButton() == Event.BUTTON_RIGHT)

if(event.getTypeInt() == Event.ONDBLCLICK)

Hope that helps
//J

arun

unread,
Feb 4, 2009, 3:37:48 AM2/4/09
to Google Web Toolkit

i tried this..but event.getTypeInt() is not capturing the doubleclick
event.is there any other way to capture double click?
> >> - Show quoted text -- Hide quoted text -

Litty Preeth

unread,
Feb 4, 2009, 4:37:42 AM2/4/09
to Google-We...@googlegroups.com
Try this eg:

public class Home extends AbsolutePanel implements EntryPoint {

     

      public void onModuleLoad() {

            init();

      }

 

      private void init() {

            RootPanel.get().add(this);

            setHeight(Window.getClientHeight()+"px");

            DOM.setStyleAttribute(getElement(), "background", "#ADDFFF");

            Label lbl = new Label();

            DOM.setStyleAttribute(lbl.getElement(), "color", "blue");

            DOM.setStyleAttribute(lbl.getElement(), "font-weight", "bold");

            DOM.setStyleAttribute(lbl.getElement(), "font-size", "16px");

            lbl.setText("Right Click OR Double Click anywhere");

            this.add(lbl);

            sinkEvents(Event.ONMOUSEDOWN);

            sinkEvents(Event.ONDBLCLICK);

      }

     

      public void onBrowserEvent(Event event) {

            super.onBrowserEvent(event);

            switch (DOM.eventGetType(event)) {

            case Event.ONMOUSEDOWN:

                  if(DOM.eventGetButton(event) == Event.BUTTON_RIGHT)

                        Window.alert("You RIGHT CLICKED");

                  break;

            case Event.ONDBLCLICK:

                  Window.alert("You DOUBLE CLICKED");

                  break;

            }

      }

}


- Litty

arun

unread,
Feb 4, 2009, 6:17:27 AM2/4/09
to Google Web Toolkit
Its working fine...The solution provided by you has struck the correct
chord.
...Thanks a lot for replying Litty.

Arun


On Feb 4, 2:37 pm, Litty Preeth <preeth.h...@gmail.com> wrote:
> Try this eg:
>
> *public* *class* Home *extends* AbsolutePanel *implements* EntryPoint {
>
>       *public* *void* onModuleLoad() {
>
>             init();
>
>       }
>
>       *private* *void* init() {
>
>             RootPanel.*get*().add(*this*);
>
>             setHeight(Window.*getClientHeight*()+"px");
>
>             DOM.*setStyleAttribute*(getElement(), "background", "#ADDFFF");
>
>             Label lbl = *new* Label();
>
>             DOM.*setStyleAttribute*(lbl.getElement(), "color", "blue");
>
>             DOM.*setStyleAttribute*(lbl.getElement(), "font-weight", "bold"
> );
>
>             DOM.*setStyleAttribute*(lbl.getElement(), "font-size", "16px");
>
>             lbl.setText("Right Click OR Double Click anywhere");
>
>             *this*.add(lbl);
>
>             sinkEvents(Event.*ONMOUSEDOWN*);
>
>             sinkEvents(Event.*ONDBLCLICK*);
>
>       }
>
>       *public* *void* onBrowserEvent(Event event) {
>
>             *super*.onBrowserEvent(event);
>
>             *switch* (DOM.*eventGetType*(event)) {
>
>             *case* Event.*ONMOUSEDOWN*:
>
>                   *if*(DOM.*eventGetButton*(event) == Event.*BUTTON_RIGHT*)
>
>                         Window.*alert*("You RIGHT CLICKED");
>
>                   *break*;
>
>             *case* Event.*ONDBLCLICK*:
>
>                   Window.*alert*("You DOUBLE CLICKED");
>
>                   *break*;
Reply all
Reply to author
Forward
0 new messages