Exchange click event between buttons

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
RhavoX
Posts: 33
Joined: Tue Jul 04, 2006 7:27 pm

Exchange click event between buttons

Post by RhavoX »

Hello ^^ I have one little question. Is there a non masochistic way of exchanging a click event between buttons? I mean to make it so that one button is aware that other has been pressed or clicked or whatever. Is this possible within the engine?? Because I want to modify buttons a bit ;p
Teh Uber-Pwner xD
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

First off, why? Just so we know what your plans are and may be able to suggest alternatives.

Maybe you have a few buttons in a row and want only one selected at any time?

All GUI elements have an OnEvent function which you could pass an event to i suppose so maybe you could pass an event, which you've created yourself, which tells it that it should un-press itself (if you're trying to do what i said above) but i think that would make it fire off an event to say it had been pressed which would no doubt cause you problems... But i'm sure you could get round that by making your own Button class and changing a few things from the standard implementation to prevent these things from happening.
Image Image Image
RhavoX
Posts: 33
Joined: Tue Jul 04, 2006 7:27 pm

Post by RhavoX »

Well I'm currently making some modifications to the gui to make it more windows-like. I've started with buttons. I've made them change color on hover which is simple part. Also when you press lmousebutton on a button and change cursor position to be out of the button without releasing the lmouse then it's appearance is changing so it doesn't look pressed ^^ and if you will hover it again then it will again change appearance to pressed ;p just like in windows. My problem hovewer is that if I press one button and do the thing described above but with hovering other buttons then those buttons change their appearance to hovered... This should not happen when a button is pressed.. That's why I want to exchange click or press event between them... I'll release the beta version when I'll get this part to wokr ;p;p;p
Teh Uber-Pwner xD
Xplod
Posts: 32
Joined: Sat Mar 29, 2008 5:48 pm
Contact:

Post by Xplod »

If I understand correctly, just do a simple bool which becomes "true" when a button is pressed... Then, if it is, don't hover other buttons...
I'm Ouverta on the chat |
Project leader/Lead Developer of Ouverta project.
RhavoX
Posts: 33
Joined: Tue Jul 04, 2006 7:27 pm

Post by RhavoX »

Yeah but how to transfer this variable to other buttons? :p so they can be aware that it is true? I don't want to use global variables because I want it to be made the "Irrlich way" as I would like this functionality to be added to the future Irrlicht versions ;p (I mean hovering and windows like behaviour and stuff ;p)
Teh Uber-Pwner xD
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

RhavoX wrote:Yeah but how to transfer this variable to other buttons? :p so they can be aware that it is true? I don't want to use global variables because I want it to be made the "Irrlich way" as I would like this functionality to be added to the future Irrlicht versions ;p (I mean hovering and windows like behaviour and stuff ;p)
Don't know if this helps but, IGUIElements store a pointer to the manager interface, so with a few changes you should be able to store a variable in the manager and any element could get it through that interface.
Post Reply