gui something

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
vegeta
Posts: 12
Joined: Fri May 12, 2006 4:56 pm
Location: the netherlands

gui something

Post by vegeta »

hey its me again

i want to make a check box and when you check it it unchecks the other two check boxes but i can't get it to find which id to uncheck
i tried:
if (driv == "EDT_OPENGL")
{
if (id == 4)
{
cbox->setChecked(false);
}
if (id == 5)
{
cbox->setChecked(false);
}
}
its actually just asking how to control the check box
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Hmm, are the ids the ids from the checkboxes ???
If you want to handle an element by it's id you should use getElementFromId(...) to get the pointer to it !!!

Code: Select all

if (driv == "EDT_OPENGL"){
  if (id == 4){
    guiEnv->getElementFromId(4, true)->setChecked(false);
  }
  if (id == 5){
    guiEnv->getElementFromId(5, true)->setChecked(false);
  }
}
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Seems like it would be smart for someone to write a radio button group. Until then, why not just do something like this...

Code: Select all

class RadioGroup
{
public:
  RadioGroup()
  {
  }

  ~RadioGroup
  {
      u32 b;
      for (b = 0; b < Boxes.size(); ++b)
         Boxes[b]->drop();
  }

  void addCheckBox(IGUICheckBox* box)
  {
      box->grab();
      Boxes.push_back(box);
  }

  void removeCheckBox(IGUICheckBox* box)
  {
      s32 n = Boxes.linear_search(box);
      if (n != -1)
      {
         Boxes[n]->drop();
         Boxes.erase(n);
      }
   }

   void setCheckedBox(IGUICheckBox* box)
   {
      u32 b;
      for (b = 0; b < Boxes.size(); ++b)
         if (Boxes[b] != box) Boxes[b]->setChecked(false);
   }

private:
   core::array<IGUICheckBox*> Boxes;
};
You would just create one of these to manage the checkbox state. Add all of the related checkboxes to one of these. Then your event receiver would just call setCheckedBox() and the other boxes would automatically get unchecked.

Another option would be to use a combo box instead. The combo box only allows one active selection, takes up less ui space and is already written and working.

Travis
vegeta
Posts: 12
Joined: Fri May 12, 2006 4:56 pm
Location: the netherlands

Post by vegeta »

wooohooo i got it working with this:
if (driv == "EDT_OPENGL")
{
d3dcheck->setChecked(false);
softcheck->setChecked(false);
}
if (driv == "EDT_DIRECT3D9")
{
opcheck->setChecked(false);
softcheck->setChecked(false);
}
if (driv == "EDT_SOFTWARE2")
{
d3dcheck->setChecked(false);
opcheck->setChecked(false);
}
i forgot the pointers
thnx for the help though
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well, or just this way... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply