How to make buttons unclickable?

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

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

How to make buttons unclickable?

Postby Protagonist » Wed Apr 04, 2007 21:20

Hi there, I was wondering if anybody knows how to make a button unclickable, but without setting it to not enabled, so it looks like an enabled button, but simply cannot be clicked.
I was thinking I could perhaps disable event capture for it, but have had no luck.
Any help would be great, thanks a lot :)

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Thu Apr 05, 2007 08:29

Hi,

you might try if calling 'setMutedState(true)' on your button does what you need. This keeps the button as-is, only while seeming to deny events, hence the name of the method.

HTH :)

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Thu Apr 05, 2007 08:42

You could also simply not subscribe to the button clicked event, but I think scriptkid's way is more efficient :P
Image
Image

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Thu Apr 05, 2007 08:59

^^ hehe didn't think about that one :)

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

Postby Protagonist » Thu Apr 05, 2007 09:33

Thanks a lot both of you :).

That's what I was looking for.

Yeah, I thought that too regarding not subscribing to the event, but I don't explicitly, yet a clicked event must be fired anyway because it changes.

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

Postby Protagonist » Thu Apr 05, 2007 09:36

Oh right, I need to call setMutedState in the onlick event? Thus making it seem like it's not accepting a click event?
Hmm, oki.

You see, maybe I shouldn't have been doing this, but I'm using buttons as table titles... one for each column, because well they look pretty, haha.

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Thu Apr 05, 2007 09:42

No not in the onClick event. Just when you create it. You dont have to subscribe to the onClick event when muting a button.
Image

Image

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

Postby Protagonist » Thu Apr 05, 2007 09:44

Okay, in that case it doesn't work. The first thing I did was try muting it when creating it..

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Thu Apr 05, 2007 09:49

Yes that should work, but as you stated it doesnt, I would just not subscribe to the onclick event. Other option is, ofcourse, disable it, but you didn't want to do that :)

Alternatively, you could edit the looknfeel, and create something new, but it requires alot of work if you are not already into Falagard mapping. I wouldnt do this if you only plan to have a 'disabled' button.
Image

Image

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Thu Apr 05, 2007 09:53

Protagonist wrote:Okay, in that case it doesn't work. The first thing I did was try muting it when creating it..


I tested this with the "quit" button in Sample7 and when i mute the button, i can click it without the application to shut down... this is the code:

Code: Select all

WindowManager ::getSingleton().getWindow("Demo7/Window1/Quit")->setMutedState(true);
    WindowManager ::getSingleton().getWindow("Demo7/Window1/Quit")->
        subscribeEvent(PushButton::EventClicked, Event::Subscriber(&Demo7Sample::handleQuit, this));


Clicks are denied... can you post your code if it still doesn't work?

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

Postby Protagonist » Thu Apr 05, 2007 10:26

Ahh well you see, I want to make it non clickable. So mutedState prevents events?
I was looking for something that has the effect of setEnabled(false), but without dimming the button, so it looks active and pretty, not greyed out.

So effectively, I have something that looks like a normal button, but isn't a button (at least it doesn't behave like one - can't be clicked)

Does that make sense?

Thanks a lot.

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Thu Apr 05, 2007 11:17

I understand what you want, but not why. You could easily do this with a statictext with a background and a frame. But if you really want the button, you will need to either use setEnabled or change the looknfeel. If you want, I can write the looknfeel entry for you, you just simply paste it in your looknfeel file, and use setLooknFeel on the button (I think that'll work, never tested though).
Image

Image

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

Postby Protagonist » Thu Apr 05, 2007 12:01

Ahh. Hmm, well I thought widget reuse would be a good idea. I didn't want to define lots of textures and stuff. If I could simply apply the texture used by the windowslook buttons to a static image that'd be cool, but I have no idea how to do that.

Thanks

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Thu Apr 05, 2007 12:05

Thats kinda like the same. The looknfeel entry of that button is going to be very simple to do. I could make it for you if you like. It would come out as a normal button, unclickable, and no hover action.
Image

Image

Protagonist
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Sat Mar 03, 2007 22:54

Postby Protagonist » Thu Apr 05, 2007 13:46

Hehe, if you don't mind, that'd be great :).

It's for the WindowsLook/PushButton

Thanks a lot


Return to “Help”

Who is online

Users browsing this forum: No registered users and 16 guests