[Solved] TabControl: Enabling / Disabling Tabs

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

TheWanderer
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Feb 03, 2016 21:58

[Solved] TabControl: Enabling / Disabling Tabs

Postby TheWanderer » Wed Feb 15, 2017 20:54

Hey all,

I've been looking through the forum for a way to achieve this and I've found a few posts, but I'm not grasping the whole picture from the answers (specifically, here and here).

To describe the situation, I'm working on a game where clicking on objects opens up a tabbed information window. Each tab exposes certain information about the object. Each object though has a particular subset of tabs which are applicable to it, so I'm looking for a way to enable the pertinent tabs and disable the rest.

Is the idea to enable / disable the tab buttons (which need to be searched by name) a good one (since they're "technically" not accessible to the user)? Does Crazzy Eddie mean to remove the child window when he states that the "Content Pane" should be removed? How can it be removed without destroying the window (since I need to re-use it)?

Any help is greatly appreciated :)

Edit: Enabling / disabling buttons is not the best solution, as the visible tab buttons don't align left, but rather remain where they would normally be if all tabs were visible.

CEGUI Info

Code: Select all

---- Version: 0.8.4 (Build: Jul 13 2016 Static Debug Microsoft Windows MSVC++ 11.0 32 bit) ----
---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
---- XML Parser module is: CEGUI::RapidXMLParser - Official RapidXML based parser module for CEGUI ----
---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
---- Scripting module is: None ----
Last edited by TheWanderer on Thu Feb 16, 2017 21:52, edited 1 time in total.

TheWanderer
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Feb 03, 2016 21:58

Re: TabControl: Enabling / Disabling Tabs

Postby TheWanderer » Thu Feb 16, 2017 21:52

After a bit of digging, I found that you can call removeChild() ( as opposed to removeTab() ) and have the TabControl remove the associated TabButton correctly without the window inside the tab being affected. You still need somewhere to keep the now orphan window, but you can then easily restore it by calling addTab() with it at a later time.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Solved] TabControl: Enabling / Disabling Tabs

Postby Ident » Thu Feb 16, 2017 22:04

Interesting, thanks for figuring this out and reporting the solution.

I would say that having to do this is a workaround and not optimal. What you would expect is that by deactivating the tab, it would become unresponsive to inputs, therefore not allowing to switch to it. Is that right?
CrazyEddie: "I don't like GUIs"

TheWanderer
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Wed Feb 03, 2016 21:58

Re: [Solved] TabControl: Enabling / Disabling Tabs

Postby TheWanderer » Thu Feb 16, 2017 23:34

More than happy to share :)

Indeed, deactivating the tab should render it unresponsive to inputs, but (at least in my case) it should also be invisible to the user. This would also include ensuring that tabs that remained visible / active had their associated tab buttons correctly positioned on the tab bar (e.g. aligned left in my case).

A possible solution would be to have an internal storage of "disabled" tabs which can be re-enabled by name / id. When disabling a particular tab, the function can move the window to this storage and then reshuffle the tab buttons as needed (as well as marking some other tab as selected, perhaps?).

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Solved] TabControl: Enabling / Disabling Tabs

Postby Ident » Fri Feb 17, 2017 19:59

Ok that is a special behaviour then and I do not think we should do this by default. In that case I would expect that removing the child and making it hidden (which I think also deactivates input handling) would be the way to go, and I think that is what you did, so no changes needed :)
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests