create text boxes in a recursive way & take control

Artic_Ice83

25-01-2008 10:52:48

Hi!
i'd like to create text boxes in recursive way, and if i try this code all works well:



TextBox *tb1;

for(int i=0;i<5;++i)
{
tb1 = panel->createTextBox(mVector.at(i));
tb1->setPosition(100,30*i);
vTextB.push_back(tb1);
}



and all text boxes display on my panel.
but i have a question: is there a way to take control of the text boxes created? i explain better my idea.
i want to add event handlers for all the text boxes.
i tried to store the tb1 pointer in a vector (see above the vTextB) and try this


vTextB.at(0)->addEventHandler(QuickGUI::Widget::EVENT_MOUSE_CLICK,&SimpleGUIDemoApp::tbMBDown,this);


but the change is only in the last text box created.
is there a way to take control of them?

kungfoomasta

25-01-2008 17:37:05

Here is the problem:

vTextB.at(0)

Consider trying this:

vTextB.at(i)

Artic_Ice83

25-01-2008 19:08:05

well, i have noted that obviously if i do how you say it works... :oops:
but now, my "problem" is the event handler...
in my event handler, when i have an EVENT_MOUSE_CLICK, i clear the text.
how can i take the text box that have fired the event?
maybe args have something that can help me?

kungfoomasta

25-01-2008 19:18:37

http://www.ogre3d.org/wiki/index.php/QuickGUI_FAQ#What_is_an_Event.2C_EventHandler.2C_and_EventArgs.3F

The WidgetEventArgs will give you access to the Widget that fired the event.

Artic_Ice83

25-01-2008 20:02:25

wow!!! now it works!!!
thanks a lot kungfoomasta! i haven't read that part of the wiki... :oops: