[Solved] Disabled button gets no Events

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

KishukuOni
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Wed Nov 25, 2009 17:41

[Solved] Disabled button gets no Events

Postby KishukuOni » Thu Jul 24, 2014 20:49

Greetings,
I am pretty sure I understand what is happening, but I wanted to hear it from the experts.
I have a button inside another window. Both the button and the parent window have Window::EventMouseClick handlers.
I end up disabling that button. Now when I click on the button the parent's EventMouseClick handler is called.
Is there a way to prevent this from happening? I still want the button to catch the click event inside it's area and not transfer it to the parent window while disabled.
If the button is enabled, it blocks the click event from going to the parent. However, it looks like windows don't get any events at all if they are disabled.

My current work around idea is to put a DefaultWindow at the exact same location as the button and have it catch the click events when the button is disabled. Has anyone else had an issue with this? Any better work-around ideas?

Thanks.

Code: Select all

24/07/2014 16:36:00 (Std)    ---- Version: 0.8.3 (Build: May 12 2014 Debug Microsoft Windows MSVC++ Great Scott! 32 bit) ----
24/07/2014 16:36:00 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
24/07/2014 16:36:00 (Std)    ---- XML Parser module is: CEGUI::TinyXMLParser - Official tinyXML based parser module for CEGUI ----
24/07/2014 16:36:00 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
24/07/2014 16:36:00 (Std)    ---- Scripting module is: None ----

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Disabled button gets no Events

Postby lucebac » Thu Jul 24, 2014 22:24

Hi KishukuOni,

after a quick look into the source I found out that your 'problem' is most likely caused by line 580 of CEGUI::Window base class.
If you disabled your button cegui simply ignores it when clicking on it - and that is wanted (and expected) behaviour. It would be strange if you disabled a button and were still able to fire off the "button clicked" signal. Thus, your assumptions are mostly correct. Windows won't handle "clicked" events if they're disabled but other events can still be handled (I don't know for sure but it would be odd if no event will be handled).
Nonetheless this is a thing that should be thought about.
Kulik is around here quite often so be patient and you will shortly get an answer from one of the core devs.

Greetings,
lucebac

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Disabled button gets no Events

Postby Ident » Tue Jul 29, 2014 19:34

Now when I click on the button the parent's EventMouseClick handler is called.
Is there a way to prevent this from happening?


Is that all you want? If yes, then doesn't

Code: Select all

whateverButtonYouDisable->setMouseInputPropagationEnabled(false)

exactly solve your issue?


Please give feedback if this solved it for you.
CrazyEddie: "I don't like GUIs"

KishukuOni
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Wed Nov 25, 2009 17:41

Re: Disabled button gets no Events

Postby KishukuOni » Mon Aug 18, 2014 17:37

Ident,
My apologies, I missed your reply.
This is the sort of easy solution I was looking for, but setting Mouse input propagation to false does not solve my issue. This is (I think) because the button never sees the event at all and thus never gets to the decision about propagating or not.
It is like the disabled child window does not exist. The parent window's is_hit() returns true and it has an EventMouseClick, therefore that gets fired.
I can see where this scenario would not come up too regularly. Let me try and explain my usage. Usually in pretty much any GUI, clicking on a parent window (like a panel or group box) does nothing (except for maybe change keyboard focus). For the game I am working on, however, the desired functionality is to click on empty space in the panel for extra info, while clicking on the CANCEL or ADD buttons do other things. Sometimes the ADD button is disabled and when you click on it you see extra info. Everyone who's tried it says it "just feels weird." Maybe this part of my GUI is just a poor design (don't tell my design architect I said that).
I am content to say that CEGUI works as intended in this case. Disabled windows completely ignoring events seems like a reasonable functionality to me. Just wanted to check.
Thanks for the feedback.
K.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Disabled button gets no Events

Postby Ident » Mon Aug 18, 2014 19:04

What if you dont disable it? You should be able to make the button disfunctional by returning true in the click-handler of it anyways. You can simply add a condition in the handler, so you can choose if u want to return true or false. Does this help?
CrazyEddie: "I don't like GUIs"

KishukuOni
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Wed Nov 25, 2009 17:41

Re: Disabled button gets no Events

Postby KishukuOni » Tue Aug 19, 2014 20:46

Yep, great idea. I set the Disabled image to the Normal, Hover, and Pushed properties so it looks disabled and everything works great. Much easier, thanks for the help.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 15 guests