Page 1 of 2
How to make buttons unclickable?
Posted: 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
Posted: Thu Apr 05, 2007 08:29
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.
Posted: 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
Posted: Thu Apr 05, 2007 08:59
^^ hehe didn't think about that one
Posted: 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.
Posted: 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?
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.
Posted: 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.
Posted: 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..
Posted: 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.
Posted: 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
subscribeEvent(PushButton::EventClicked, Event::Subscriber(&Demo7Sample::handleQuit, this));
Clicks are denied... can you post your code if it still doesn't work?
Posted: 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.
Posted: 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).
Posted: 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.
Posted: 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.
Posted: 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