RookieBeotch
RookieBeotch

Reputation: 93

Nasa World Wind: SelectListener not triggering on map clicks

I'm using java WWsdk. I am expecting the SelectListener to respond to user clicks on the map when user clicks just the map (i.e. not an icon or placemark,etc..).

It works fine for me when i click on my objects, but it doesn't trigger when i click "empty space". i.e. like water/land.

The docs for SelectListener says

If no object is under the cursor but the cursor is over terrain, the select event will >identify the terrain as the picked object and will include the corresponding geographic >position

This statement makes it sound like i should get an event whenever i don't click an object,but i don't get this.

Am i supposed to add some other kind of layer to get clicks on map to trigger select events?

I use this which is working for me for actions i need performed on objects that get clicked:

this.worldWindowGLCanvas1.addSelectListener(new SelectListener()
    {
        public void selected(SelectEvent event)
        {
             //Never goes here for clicks on map, just clicks
             //on objects i have already created.     
             doStuff();
        }
     }

Upvotes: 1

Views: 749

Answers (1)

Chris K
Chris K

Reputation: 1723

Add a MouseListener using addMouseListener():

this.worldWindowGLCanvas1.addMouseListener(new MouseListener() {
    @Override
    public void mouseClicked(MouseEvent e) {
        doStuff();
    }
    ...
}

You may also want to add the listener to the AWTInputHandler instead of the WorldWindowGLCanvas if you want to prevent World Wind from doing something else with the click. More details in this question.

Upvotes: 1

Related Questions