![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Aug 2009
Posts: 152
|
I'm trying to add a select listener to a screen annotation but I can't seem to get it to work. I have a simple renderable layer and as a test added one ImageAnnotation. I then add a select listener to the ww canvas, but I never see a select event when the mouse is over the annotation. Should I? If not, I'm not sure I understand...That seems to be how the View Controls layer works.
thanks, Jeff Last edited by patmurris; 11-30-2009 at 05:31 PM. Reason: Solved |
|
|
|
|
|
#2 |
|
Super Member
Join Date: Nov 2006
Location: 35.0376,-117.9688
Posts: 1,519
|
Take a look at several of the examples that use picking, like DraggingShapes.
I don't recall what is necessary other than: Code:
import gov.nasa.worldwind.event.SelectEvent;
import gov.nasa.worldwind.event.SelectListener;
and
wwd.addSelectListener(new SelectListener(){
public void selected(SelectEvent event){
if (event.getEventAction().equals(SelectEvent.LEFT_CLICK)
&& event.hasObjects()
&& event.getTopObject() instanceof Polyline){
positions = (ArrayList<Position>) ((Polyline) event.getTopObject()).getPositions();
System.out.println("#39 PathsList: " + positions);
}
}
});
For mouse over it would be "SelectEvent.ROLLOVER" I just used the above code for initial testing. DraggingShapes has the Object highlighted. Last edited by nlneilson; 11-23-2009 at 11:50 PM. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2009
Posts: 152
|
Hmm...that's what I thought but I just put a println in the selected method and I'm not even seeing that being called when I mouse over or click on the screen annotation. I tried removing the other select listener I have for the view controls but that didn't fix anything either. I'll investigate further...thanks.
|
|
|
|
|
|
#4 |
|
Super Member
Join Date: Nov 2006
Location: 35.0376,-117.9688
Posts: 1,519
|
You might need to put this in your main, but if you are using View Controls also it should all ready be in somewhere.
import gov.nasa.worldwind.pick.PickedObjectList ; edit: Look at examples.Annotations.java, it has: import gov.nasa.worldwind.pick.*; I don't use ApplicationTemplate so your app may be different. Last edited by nlneilson; 11-24-2009 at 12:53 AM. |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Aug 2009
Posts: 152
|
As you suspected, that didn't really do anything. Would it be incorrect to have 2 select listeners (though removing one of them didn't help). I'll let you know if I can figure anything out.
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Aug 2009
Posts: 152
|
I think I inadvertently had an overridden method from AbstractLayer (doPick) and didn't call super first and I think that broke it.
|
|
|
|
|
|
#7 |
|
Super Member
Join Date: Nov 2006
Location: 35.0376,-117.9688
Posts: 1,519
|
Run examples.Annotations.java, and then see where your app/layer is different.
|
|
|
|
|
|
#8 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
|
Is your layer pick enabled?
|
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Aug 2009
Posts: 152
|
My layer extended RenderableLayer and I had overridden doPick and not called the super doPick and that seemed to fix the issue. Thanks.
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Solved] Annotation Select | agreen53 | Development Help | 11 | 08-04-2009 12:42 PM |
| How to add a Java listener for position change? | emaronchi | Development Help | 6 | 04-13-2008 11:08 PM |
| File listener | nlneilson | Development Help | 0 | 03-29-2008 10:34 PM |
| Mouse Listener | ayman | Development Help | 1 | 03-16-2008 09:51 AM |
| Select many icons | Akhesa | Development Help | 1 | 02-20-2008 12:00 AM |