Mouse Event

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Mouse Event

alcesgabbo
Hello everybody,

How can I "emulate" the click of the mouse on the map?

For example with a command like this:

.clickOnTheMap(currentMap,coordinates);

Thanks.
Alberto

_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users
Reply | Threaded
Open this post in threaded view
|

Re: [udig-devel] Mouse Event

Jody Garnett-2
Mouse events are sent to the current tool. Tour can hunt down this
tool (use applicationgis to find the tool manager) and then send it
mouse event objects. You may wish to do so from the display thread.

To simulate mouse and keyboard interaction more generally for test
cases use SWTBot

--
Jody Garnett

On 07/02/2012, at 12:31 AM, Alberto Debiasi <[hidden email]> wrote:

> Hello everybody,
>
> How can I "emulate" the click of the mouse on the map?
>
> For example with a command like this:
>
> .clickOnTheMap(currentMap,coordinates);
>
> Thanks.
> Alberto
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users
Reply | Threaded
Open this post in threaded view
|

Re: [udig-devel] Mouse Event

alcesgabbo
Thanks for the response,
I tried to follow your suggestion:
     
 PointTool pointTool =.....
        IMapDisplay mapDisplay=map.getRenderManager().getMapDisplay();
//I create a mouse event
        MapMouseEvent mouseEvent = new MapMouseEvent(mapDisplay,10,10,0,1,1);       
        pt.mousePressed(mouseEvent);

But I have an exception:

Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:3563)
    at org.eclipse.swt.SWT.error(SWT.java:3481)
    at org.eclipse.swt.SWT.error(SWT.java:3452)
    at net.refractions.udig.tools.edit.MouseTracker.checkAccess(MouseTracker.java:96)
    at net.refractions.udig.tools.edit.MouseTracker.updateState(MouseTracker.java:56)
    at net.refractions.udig.tools.edit.EditToolHandler.handleEvent(EditToolHandler.java:227)
    at net.refractions.udig.tools.edit.AbstractEditTool.onMousePressed(AbstractEditTool.java:235)
    at net.refractions.udig.project.ui.tool.SimpleTool.mousePressed(SimpleTool.java:142)

In particular in the method checkAccess() in the class MouseTracker:

 private void checkAccess() {
        if( Display.getCurrent()==null )
            SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
    }


Alberto.

2012/2/6 Jody Garnett <[hidden email]>
Mouse events are sent to the current tool. Tour can hunt down this
tool (use applicationgis to find the tool manager) and then send it
mouse event objects. You may wish to do so from the display thread.

To simulate mouse and keyboard interaction more generally for test
cases use SWTBot

--
Jody Garnett

On 07/02/2012, at 12:31 AM, Alberto Debiasi <[hidden email]> wrote:

> Hello everybody,
>
> How can I "emulate" the click of the mouse on the map?
>
> For example with a command like this:
>
> .clickOnTheMap(currentMap,coordinates);
>
> Thanks.
> Alberto
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users


_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users
Reply | Threaded
Open this post in threaded view
|

Re: [udig-devel] Mouse Event

Andrea Antonello
Please Alberto,
do not crosspost development questions in the user list.
The udig-devel is here for that.

Closing this thread in the users list now.

[...]

> Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Invalid
> thread access
>     at org.eclipse.swt.SWT.error(SWT.java:3563)
>     at org.eclipse.swt.SWT.error(SWT.java:3481)
>     at org.eclipse.swt.SWT.error(SWT.java:3452)
>     at
> net.refractions.udig.tools.edit.MouseTracker.checkAccess(MouseTracker.java:96)
>     at
> net.refractions.udig.tools.edit.MouseTracker.updateState(MouseTracker.java:56)
>     at
> net.refractions.udig.tools.edit.EditToolHandler.handleEvent(EditToolHandler.java:227)
>     at
> net.refractions.udig.tools.edit.AbstractEditTool.onMousePressed(AbstractEditTool.java:235)
>     at
> net.refractions.udig.project.ui.tool.SimpleTool.mousePressed(SimpleTool.java:142)

You should run this in the UI thread, which you can do with:
Display.getDefault().asyncExec(new Runnable(){
    public void run() {
         // do your stuff here
    }
});


Ciao,
Andrea


>
> In particular in the method checkAccess() in the class MouseTracker:
>
>  private void checkAccess() {
>         if( Display.getCurrent()==null )
>             SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
>     }
>
>
> Alberto.
>
>
> 2012/2/6 Jody Garnett <[hidden email]>
>>
>> Mouse events are sent to the current tool. Tour can hunt down this
>> tool (use applicationgis to find the tool manager) and then send it
>> mouse event objects. You may wish to do so from the display thread.
>>
>> To simulate mouse and keyboard interaction more generally for test
>> cases use SWTBot
>>
>> --
>> Jody Garnett
>>
>> On 07/02/2012, at 12:31 AM, Alberto Debiasi <[hidden email]>
>> wrote:
>>
>> > Hello everybody,
>> >
>> > How can I "emulate" the click of the mouse on the map?
>> >
>> > For example with a command like this:
>> >
>> > .clickOnTheMap(currentMap,coordinates);
>> >
>> > Thanks.
>> > Alberto
>> > _______________________________________________
>> > User-friendly Desktop Internet GIS (uDig)
>> > http://udig.refractions.net
>> > http://lists.refractions.net/mailman/listinfo/udig-devel
>> _______________________________________________
>> udig-users mailing list
>> [hidden email]
>> http://lists.refractions.net/mailman/listinfo/udig-users
>
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>
_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users