Listbox::EventMouseClick event firing twice

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Listbox::EventMouseClick event firing twice

Postby Arcanor » Thu Jan 15, 2009 05:12

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. :)
Arcanoria - a SMORPG project - http://www.arcanoria.com

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Thu Jan 15, 2009 20:12

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.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Thu Jan 15, 2009 20:52

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!

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Postby Arcanor » Thu Jan 15, 2009 21:10

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

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Postby Arcanor » Thu Jan 15, 2009 21:13

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

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Fri Jan 16, 2009 07:51

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 ;)

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Postby Arcanor » Fri Jan 16, 2009 10:37

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


Return to “Help”

Who is online

Users browsing this forum: No registered users and 21 guests