I've got a Listbox, containing several ListboxTextItems. I'm subscribing to the Listbox::EventMouseClick and sending it to a function named h_InteractionChoiceMouseClick.
I've only subscribed once, yet the event is firing twice each time I click in the Listbox. Why is this happening? How can I prevent the event from being processed twice?
Since WindowEventArgs doesn't give me any information about the mouse state I can't test to see if the mouse button is up or down.
Any ideas?
Thanks in advance.
Listbox::EventMouseClick event firing twice
Moderators: CEGUI MVP, CEGUI Team
Listbox::EventMouseClick event firing twice
Arcanoria - a SMORPG project - http://www.arcanoria.com
First, I have serious doubts about EventMouseClick fireing twice for no reason; this event is handled by the Window base class, and I haven't had any issues with this event on other Window-based objects. But who knows?
Second, have you tried using a different event, like EventMouseButtonDown (should only fire once)? or EventSelectionChanged (fires 2x, for deselection and reselection)? Do these exhibit correct/incorrect behavior?
Third, is there a particular reason why you using WindowEventArgs for a Mouse event? You can typecast the EventArgs parameter to MouseEventArgs for mouse-based events.
Second, have you tried using a different event, like EventMouseButtonDown (should only fire once)? or EventSelectionChanged (fires 2x, for deselection and reselection)? Do these exhibit correct/incorrect behavior?
Third, is there a particular reason why you using WindowEventArgs for a Mouse event? You can typecast the EventArgs parameter to MouseEventArgs for mouse-based events.
Jamarr wrote:First, I have serious doubts about EventMouseClick fireing twice for no reason; this event is handled by the Window base class, and I haven't had any issues with this event on other Window-based objects. But who knows?
Second, have you tried using a different event, like EventMouseButtonDown (should only fire once)? or EventSelectionChanged (fires 2x, for deselection and reselection)? Do these exhibit correct/incorrect behavior?
Third, is there a particular reason why you using WindowEventArgs for a Mouse event? You can typecast the EventArgs parameter to MouseEventArgs for mouse-based events.
Thanks for the reply Jamarr. To answer your points:
1. I agree that there must be a reason, and that it's probably something I did wrong. I'm not an expert with events.
2. I am seeing the same (incorrectly firing twice) behavior even if I use a different event such as EventMouseButtonDown.
3. Actually I didn't realize that I could use MouseEventArgs for this. I had read in several other posts that the EventMouseClick is actually not considered a mouse event, but rather a window event. Thanks for letting me know that I can simply recast this and access the other elements relevant to a mouse! This is very helpful.
Arcanoria - a SMORPG project - http://www.arcanoria.com
Pompei2 wrote:You could also try to subscribe to this event in another window (other then listbox) and see what happens there (should be the same)
Also, make sure you don't inject something twice while injecting input into CEGUI!
Thanks for your reply Pompei2. I did try this as well and I'm still getting the event firing twice, even though I use a plain StaticImage and not a Listbox.
I'm sorry to say it looks like I will need to find my answer elsewhere. At this point, I think it's most likely that there's a problem with my use of the framework I'm using to generate the mouse input events. I will look there.
Thanks everyone for your kind advice.
Arcanoria - a SMORPG project - http://www.arcanoria.com
Just a hint for the future:
I think if you are unsure about something and the documentation doesn't help, you could just try it out using the dynamic_cast, he tells you if it works or not
Arcanor wrote:Thanks for letting me know that I can simply recast this and access the other elements relevant to a mouse! This is very helpful.
I think if you are unsure about something and the documentation doesn't help, you could just try it out using the dynamic_cast, he tells you if it works or not
Pompei2 wrote:Just a hint for the future:Arcanor wrote:Thanks for letting me know that I can simply recast this and access the other elements relevant to a mouse! This is very helpful.
I think if you are unsure about something and the documentation doesn't help, you could just try it out using the dynamic_cast, he tells you if it works or not
Thanks Pompei2.
Arcanoria - a SMORPG project - http://www.arcanoria.com
Who is online
Users browsing this forum: No registered users and 16 guests