I have some List and TileList controls. How can I get a reference to the list item that’s currently under the mouse pointer?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Thanks for the answers so far. I ultimately came up with something different, and thought I would share it as well. The main reason I opted for this solution is because I am actually responding to an external event, as I am using the custom context menu library to capture the right-click in Javascript. When the right-click is happening, the user may not necessarily be moving the mouse. I could keep track of which item the pointer is over at all times, but I thought that would get complicated. Anyhow my solution worked by subclassing List, some thing like:
Now you can call list.findItemIndexForMouse() to get the index of the item given the mouse’s stage coordinates. Make sure you use the mx_internal namespace, or you won’t have access to some of the required instance variables. For TileList you have to do the same thing except the method looks a bit different: