[SOLVED] H: Can not getUserData() from the current Tab.
Posted: Mon Mar 02, 2009 00:39
CEGUI: 0.6.2
How does one get their user data and ID from a tab they created?
This does NOT work:
and then when the CEGUI::TabControl fires off the EventSelectionChanged event...
mTabWindow->getID() < 1 fails. Refer to this line when the tab is created: mNewTabItem->TabWindow->setID( mNewTabItem->TabNumber );
So, how can I do a getUserData() so I can get my data that I assigned way back up in mNewTabItem->TabWindow->setUserData( mNewTabItem );
It appears that the window being returned to me as the current tab is not really the window I created.
How does one get their user data and ID from a tab they created?
This does NOT work:
Code: Select all
...
mLastTabNumber++;
mNewTabItem->TabNumber = mLastTabNumber;
...
// Create the new TAB
mNewTabItem->TabWindow = ( CEGUI::DefaultWindow *) CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", mTemp );
mTabControl->addTab( mNewTabItem->TabWindow );
mNewTabItem->TabWindow->setFont( mNewTabItem->Font );
mNewTabItem->TabWindow->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.0f, 0.0f ), CEGUI::UDim( 0.0f, 0.0f ) ) );
mNewTabItem->TabWindow->setSize( CEGUI::UVector2( CEGUI::UDim( 1.0f, 0.0f ), CEGUI::UDim( 1.0f, 0.0f ) ) );
mNewTabItem->TabWindow->setText( mTabName );
mNewTabItem->TabWindow->setUserData( mNewTabItem );
mNewTabItem->TabWindow->setID( mNewTabItem->TabNumber );
...
and then when the CEGUI::TabControl fires off the EventSelectionChanged event...
Code: Select all
bool clsGUIChat::event_TabControl_TabChange(const CEGUI::EventArgs& e)
{
// Get the current tab from the tab control.
CEGUI::Window *mTabWindow = mTabControl->getActiveChild();
if ( !mTabWindow || mTabWindow->getID() < 1 ) return true;
// Can this tab be deleted?
if ( mTabWindow->getID() == 1 )
mPopupMenu[ PUM_MAIN ]->getChild( "Chat/PopupMenu/Tab/Delete" )->setEnabled( false );
else
mPopupMenu[ PUM_MAIN ]->getChild( "Chat/PopupMenu/Tab/Delete" )->setEnabled( true ); // Default
// Update current Tab Item and Fonts.
mCurrentTabItem = (tTabItem *) mTabWindow->getUserData();
if ( mCurrentTabItem )
{
setTabFont( mCurrentTabItem, mCurrentTabItem->Font );
refreshTabFonts();
} // mCurrentTabItem?
return true;
} // event_TabControl_TabChange
mTabWindow->getID() < 1 fails. Refer to this line when the tab is created: mNewTabItem->TabWindow->setID( mNewTabItem->TabNumber );
So, how can I do a getUserData() so I can get my data that I assigned way back up in mNewTabItem->TabWindow->setUserData( mNewTabItem );
It appears that the window being returned to me as the current tab is not really the window I created.