The behavior I would most like is to be able to disable and enable tab buttons of a tab control. For instance, there could be cases where you have a tab control with multiple tab pages, but you only want the user to access another tab page with proper requirements met.
There does not appear to be ability to do this?
A 'fake' way of doing it might be adding/removing the tabs as needed. However, after removing/adding the same tab multiple times, it will eventually give an alreadyexists exception.
So, any thoughts?
Enable/disable tabs
Moderators: CEGUI MVP, CEGUI Team
You could "find" the button widget that is used to switch from one pane to the other and disable it. Going through the addTab() code within src/elements/CeguiTabControl.cpp:makeButtonName() indicates that the name of the button is:
Or if you know the handle of the tab pane you could use getButtonForTabContents() to retrieve the TabButton directly.
Or you can recursively iterate through the TabControl's children until you find one that contains the TabButtonNameSuffix tag and is of type TabButton.
At work we trap the "a widget is being modified" event and disable every tab except the current one (which contains the widget being modified) and then reactivate the other tabs when the user cancels or saves. One day I'll write a Cegui function that mimics that behavior, something along the lines of:
I see that as an extension of what you are seeking.
Code: Select all
String buttonName = getTabButtonPane()->getName();
buttonName.append(TabButtonNameSuffix);
size_t pathEndPos = wnd->getName().find_last_of("/");
buttonName.append(wnd->getName().substr(pathEndPos == String::npos ? 0 : pathEndPos + 1));
Or if you know the handle of the tab pane you could use getButtonForTabContents() to retrieve the TabButton directly.
Or you can recursively iterate through the TabControl's children until you find one that contains the TabButtonNameSuffix tag and is of type TabButton.
At work we trap the "a widget is being modified" event and disable every tab except the current one (which contains the widget being modified) and then reactivate the other tabs when the user cancels or saves. One day I'll write a Cegui function that mimics that behavior, something along the lines of:
Code: Select all
void setTabButtons(const CEGUI::TabControl* pTabControl, const CEGUI::String& pTabButtonName, const bool& pEnable)
{
for(iterator = first_tab_button; iterator != last_tab_button; iterator++)
{
if( (*iterator).compare(pTabButtonName) != 0 )
{
windowManager.setWindowEnable( (*iterator), pEnable);
}
}
}
I see that as an extension of what you are seeking.
The name of the tab button is generated from a formula based on the TabControl name. Bypass everything and go that way...or recursively display the name of every child of that TabControl until you find the one that makes sense then use getWindow("name of the tab button")->setEnabled(false).
Maybe I'll have some Cegui time this week and provide the complete answer.
Maybe I'll have some Cegui time this week and provide the complete answer.
Sorry if it seems like I am looking for a complete answer. It's not that, it's just that this would be a 'nice to have' before the next deadline, but it's not vital either. I don't really have the time to spend going through the code of CEGUI itself. Combined with me being a little flabbergasted that this basic functionality is not already exposed through a function ( but, it's not completely reasonable to expect anybody to foresee the needs of the users, either ) makes me a little ancy.
I do realize I can use get window to get it from the CEGUI system; but as you said, the name is generated, and I don't have the time to go hunting for that...not for this delivery anyway. I'll keep this thread under my hat, and it'll probably be a future enhancement.
Thanks for the help.
I do realize I can use get window to get it from the CEGUI system; but as you said, the name is generated, and I don't have the time to go hunting for that...not for this delivery anyway. I'll keep this thread under my hat, and it'll probably be a future enhancement.
Thanks for the help.
Here's the snippet you need to go through the children of the tab control.
You'd call it with the pointer to the TabControl window and somehow display the name of each child, or send it to the log file. It should be pretty easy to find the proper window name and derive the button name, which is based on the tab control name, a constant name, and the name of the button (I think).
Code: Select all
void processChildren(CEGUI::Window* pWindow)
{
for(size_t childIdx = 0;
childIdx < pWindow>getChildCount();
childIdx++)
{
DISPLAY WINDOW NAME OF: pWindow->getChildAtIdx(childIdx)->getName();
processChildren(pWindow->getChildAtIdx(childIdx));
}
}
You'd call it with the pointer to the TabControl window and somehow display the name of each child, or send it to the log file. It should be pretty easy to find the proper window name and derive the button name, which is based on the tab control name, a constant name, and the name of the button (I think).
Who is online
Users browsing this forum: Google [Bot] and 14 guests