Have a look at the code for getRelativeX/Y in MouseEvent.

BTW, why do you use Event.getCurrentEvent() instead of the 'event' argument?

You could also simply addClickHandler (or addDomHandler for 
ClickEvent.getType()) instead of overriding onBrowserEvent.

On Sunday, December 2, 2012 2:06:34 PM UTC+1, darkflame wrote:
>
>
> I have some rather complex click handling code on a widget that has 
> the following sort of structure: 
>
> @Override 
> public void onBrowserEvent(Event event) { 
>                 event.cancelBubble(true); 
>                             event.preventDefault(); 
>
> switch (DOM.eventGetType(event)) { 
>
>                 case Event.ONCLICK: 
>
>
>                                 int x = 
> Event.getCurrentEvent().getClientX(); 
>                                 int y = 
> Event.getCurrentEvent().getClientY(); 
>
>                                 //how to get relative X/Y from the element 
> that was clicked. 
>
>                                           (stuff to run onclick) 
>
>                 case Event....(handles other forms of mouse action) 
>
>
>
>
> This works well, and lets handle everything as needed. 
> However, because I am using a Event rather then a ClickEvent, theres 
> no easy way to get the x/y of the click relative to the element that 
> fired it. 
> Is there any way to get this information? 
> I dont think I can cast to ClickEvent, so I need to parse over the 
> whole dom tree to convert from screen x/y to element-relative x/y? 
> Seems complex Is there a better way? 
>
> Thanks, 
> Thomas 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/LQjCslGcL2YJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to