Does irrlicht have radio 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
Mloren
Posts: 114
Joined: Mon Aug 07, 2006 2:30 am
Location: Australia
Contact:

Does irrlicht have radio buttons?

Post by Mloren »

I can't seem to find any GUI element corresponding to radio buttons.
(these: http://en.wikipedia.org/wiki/Radio_button )

Does irrlicht not have anything like this?
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

No, sorry, no radiobuttons so far. I have coded some myself once, but I just took a look at the sources and it seems they also needed at least 2 patches to Irrlicht (I'll take a look at those when I find time...) and additionally couldn't be serialized.
If you still want to take a look. I think the radio-checkboxes might even work, although also without correct serialization:

http://www.michaelzeilfelder.de/irrlich ... ngroup.cpp
http://www.michaelzeilfelder.de/irrlich ... tongroup.h
http://www.michaelzeilfelder.de/irrlich ... xgroup.cpp
http://www.michaelzeilfelder.de/irrlich ... boxgroup.h
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Where should I place those .cpp and .h files?
How to use the API declared inside?
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Hm, I should clean that up some time ... anyway - you put the gui_radiocheckboxgroup.h/.cpp in your project. Probably you need a few minor changes to compile: kickout gui_element_factory.h and define MEGET_RADIOCHECKBOXGROUP_CHANGED somewhere (must be larger than EGUI_EVENT_TYPE, so setting it to EGET_COUNT +1 should work).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

How about MGUIET_RADIOCHECKBOXGROUP?
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

wsw1231 wrote:How about MGUIET_RADIOCHECKBOXGROUP?
Basically doesn't matter unless you need serialization. It's just used for factories, so set you can just replace it by 0 for now.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

How to make the checkbox appear?

Code: Select all

CGUIRadioCheckBoxGroup *c =	(CGUIRadioCheckBoxGroup*)env->addGUIElement("...", XX);
c->setRelativePostion(...);
I use the above code but the program will crash....
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

addGuiElement is for factories (and before you ask - a factory is a function that can create objects, for example when you give it a name or a type. And by adding factories you can do very flexible stuff like saving&loading gui-elements from xml, even when the engine doesn't know about them. But that's probably nothing you need for now).

What you do is simply to create it with new. And then you create checkboxes and add them to this class. Then CGUIRadioCheckBoxGroup takes care that only one checkbox is always pressed.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Code: Select all

CGUIRadioCheckBoxGroup *c =	new CGUIRadioCheckBoxGroup(env,env->getRootGUIElement());
	IGUICheckBox* a = env->addCheckBox(false, core::rect<s32>(80,100,125,120), env->getRootGUIElement(), 12, L"Kitchen");
	IGUICheckBox* aa = env->addCheckBox(false, core::rect<s32>(80,130,125,150), env->getRootGUIElement(), 23, L"aa");
	IGUICheckBox* aaa = env->addCheckBox(false, core::rect<s32>(80,160,125,180), env->getRootGUIElement(), 34, L"Kitddchen");
	c->add(a);
	c->add(aa);
	c->add(aaa);
I use the above code, but nothing is shown, even the checkboxes and the labels :(
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Sorry, can't test right now. I think you have to set the size of the group as well with setRelativePosition, otherwise the childs are clipped.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply