Page 1 of 1

gui something

Posted: Fri May 26, 2006 6:29 am
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

Posted: Fri May 26, 2006 1:10 pm
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);
  }
}

Posted: Fri May 26, 2006 6:25 pm
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

Posted: Sun May 28, 2006 5:03 am
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

Posted: Sun May 28, 2006 12:22 pm
by Acki
Well, or just this way... :lol: