When I listen for MouseDown events on a GraphicsLayer, I usually get a Graphic as the target, but when I use a UniqueValueRenderer I get a CustomSprite. I am using Picture Marker Symbols to display point data. Does anybody know how to get the graphic from a MouseDown on a GraphicsLayer using a UniqueValueRenderer?
It actually has more to do with the PictureMarkerSymbol than the UniqueValueRenderer.
The way to avoid this is to set mouseChildren = "false".
Thanks for your quick reply!
I was actually looking at the mouseChildren attribute. Symbols don't seem to have a mouseChildren attribute, and the graphicAdd event never seems to be triggered, so I can't set it for the Graphic. Do you mean that I should set mouseChildren=false for the GraphicsLayer?
No, if you are not adding your graphics in code then you will just have to climb up the parent object with your click event so on mouseDown check to see if it is a customSprite and if it is then do event.currentTarget.parent instead.
You could also set mouseChildren to false on the Graphic.
Thanks for your response.
I was trying to set mouseChildren on the Graphic, but I couldn't get access to it, since the graphicAdd event was never fired. I don't know why this is. The GraphicsLayer's dataProvider is a QueryTask, and when the query returns, the graphics get updated, but no graphicAdd events.