Accessing Button States

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Accessing Button States

Post by Tyn »

Hey

I noticed that the button's don't have a function to set and unset the button's pressed state. Looking through the docs I don't see a way of manually triggering an event, or even if I could affecting the pressed/left up image that is displayed. I can hack my way around the latter by changing the image displayed but that doesn't help with manually setting the event receiver to see my event. Or even if I could, it's still a bad way to work it.

Shouldn't be hard to add, just send the same event of when the button is clicked and left up to the event receiver using functions, I may even add it myself if I get to the stage where I need it. Still, should be there in the button class IMO.

The use I have for it is this. I have four buttons, each which set a state ( a movement state in one case, from walk to run to crouch to prone ). I need them to be push buttons and when one is pushed for the others to come up as I can only have one state. As it stands this is impossible.
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

I also needed this and just added the following to CGUIButton.cpp:

Code: Select all

void CGUIButton::setPressed(bool pressed)
{
	Pressed = pressed;
}
(including virtual declarations in CGUIButton.h & IGUIButton.h of course)

I didn't need the event thing because I was just unpressing buttons of a group exacly like you are describing. And one event is sent anyway because you're actually pushing one button of the group.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Cool, I'll wack that in. I am a little wary of messing with the engine since I didn't manage to compile it the first time and have steered as clear as possible away ever since. Had the DirectX SDK and that but couldn't be bothered to see what the error messages were and try to fix them ( plus I didn't really know that much about what compiler messages meant, learnt mainly from a book and a few small projects before messing with Irrlicht ).
Post Reply