Hi,
I'm using CELayoutEditor to create a tab control. For some reason when I'm running the application (which load the XML layout and create the CEGUI controls) and click on the tabs, the selecated window does not get changed.
I tried to implement the tab selection on my own, but I couldn't find a way to listen to the TabButtons events.
Can anyone give me a clue?
Thanks,
Shlomi.
TabControl not working with clicks
Moderators: CEGUI MVP, CEGUI Team
Assuming root is a CEGUI::Window pointer (CEGUI::Window *) that points to the root of the window. You can do the following to listen to events:
In my case the TabControl was named "TabControl" and the complete path was "HighscoreRoot/HighscoreWindow/TabControl".
The method to be called was onHighscoreTabChange in the class HighscoreWindow and the registration took place in the instance that was to listen so I used the this pointer for the last argument:
You have now pointed out the method in the class. Here's is a part of my listener function:
Having said that, and only used TabControl once, I believe the TabControl should work right away if the components specific for each tabpage are children to their respective window (tabpage) and not the TabControl.
Regards
Nimos
Code: Select all
// Add listener to the TabControl that will be called when the tab selection changes
root->getChildRecursive("<insert complete path to tabcontrol from xml file>")->subscribeEvent(CEGUI::TabControl::EventSelectionChanged, CEGUI::Event::Subscriber(&<insert name of class that contains the function to be called when event occurs>::<name function to be called when event occurs>, <pointer to instance of the class>));
In my case the TabControl was named "TabControl" and the complete path was "HighscoreRoot/HighscoreWindow/TabControl".
The method to be called was onHighscoreTabChange in the class HighscoreWindow and the registration took place in the instance that was to listen so I used the this pointer for the last argument:
Code: Select all
root->getChildRecursive("HighscoreRoot/HighscoreWindow/TabControl")->subscribeEvent(CEGUI::TabControl::EventSelectionChanged, CEGUI::Event::Subscriber(&HighscoreWindow::onHighscoreTabChange, this));
You have now pointed out the method in the class. Here's is a part of my listener function:
Code: Select all
// Listener function
bool HighscoreWindow::onHighscoreTabChange(const CEGUI::EventArgs& e)
{
const CEGUI::TabControl* tabControl = static_cast<CEGUI::TabControl *>(m_pHighscoreWindow->getChildRecursive("HighscoreRoot/HighscoreWindow/TabControl"));
switch(tabControl->getSelectedTabIndex())
{
case 0: // Do something
..
..
}
return true;
}
Having said that, and only used TabControl once, I believe the TabControl should work right away if the components specific for each tabpage are children to their respective window (tabpage) and not the TabControl.
Regards
Nimos
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
Also have a look at the TabControlDemo, which might give additional insights to the earlier post.
HTH.
Also have a look at the TabControlDemo, which might give additional insights to the earlier post.
HTH.
Check out my released snake game using Cegui!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Thanks for your replies.
I've added the listener and it still doesn't work.
I'm using Layout Editor and when I create a tab control it adds a TabControl and some DefaultWindow objects as its children.
When I click on the tab buttons I get no call to the handler of TabControl::EventSelectionChanged, though I can see that the text of the tab button is highlighted.
I noticed that the sample is loading a layout into the tab control via code, and I'm just creating the tab control pages as its children.
Any ideas what is going on?
Thanks,
Shlomi.
I've added the listener and it still doesn't work.
I'm using Layout Editor and when I create a tab control it adds a TabControl and some DefaultWindow objects as its children.
When I click on the tab buttons I get no call to the handler of TabControl::EventSelectionChanged, though I can see that the text of the tab button is highlighted.
I noticed that the sample is loading a layout into the tab control via code, and I'm just creating the tab control pages as its children.
Any ideas what is going on?
Thanks,
Shlomi.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi Eddie,
Here is the layout file:
We are loading the layout as usual, and the tab buttons become active as I hover with the mouse on them. For some reason when I click them the tab doesn't change.
Thanks!
Shlomi.
Here is the layout file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<GUILayout >
<Window Type="DefaultWindow" Name="preferences" >
<Property Name="AlwaysOnTop" Value="True" />
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
<Window Type="TaharezLook/FrameWindow" Name="GP_Window" >
<Property Name="Text" Value="Game Preferences" />
<Property Name="TitlebarFont" Value="Commonwealth-10" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="TitlebarEnabled" Value="True" />
<Property Name="UnifiedAreaRect" Value="{{0.191601,0},{0.187983,0},{0.797071,0},{0.726844,0}}" />
<Window Type="TaharezLook/Button" Name="GP_Cancel" >
<Property Name="Text" Value="Cancel" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.15845,0},{0.887739,0},{0.40845,0},{0.97941,0}}" />
</Window>
<Window Type="TaharezLook/Button" Name="GP_Apply" >
<Property Name="Text" Value="Apply" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.561419,0},{0.888784,0},{0.811419,0},{0.980455,0}}" />
</Window>
<Window Type="TaharezLook/Button" Name="GP_Next_Tab" >
<Property Name="Text" Value=">>" />
<Property Name="AlwaysOnTop" Value="True" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.403462,0},{0.115504,0},{0.495918,0},{0.179963,0}}" />
</Window>
<Window Type="TaharezLook/TabControl" Name="GP_Tabs" >
<Property Name="TabHeight" Value="{0,31.7026}" />
<Property Name="AlwaysOnTop" Value="True" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="TabPanePosition" Value="Top" />
<Property Name="UnifiedAreaRect" Value="{{0.0261617,0},{0.110059,0},{0.971736,0},{0.862275,0}}" />
<Window Type="DefaultWindow" Name="GP_General//Tab 1" >
<Property Name="Text" Value="General" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.002037,0},{-0.003262,0},{0.998295,0},{0.995408,0}}" />
</Window>
<Window Type="DefaultWindow" Name="GP_Graphics//Tab 2" >
<Property Name="Text" Value="Graphics" />
<Property Name="Visible" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.002037,0},{-0.003262,0},{0.998295,0},{0.995408,0}}" />
<Window Type="TaharezLook/RadioButton" Name="GP_Quality_Low" >
<Property Name="Text" Value="Low" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.390105,0},{0.0739286,0},{0.640105,0},{0.160323,0}}" />
</Window>
<Window Type="TaharezLook/RadioButton" Name="GP_Quality_Medium" >
<Property Name="Text" Value="Meduim" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.390105,0},{0.173929,0},{0.640105,0},{0.281146,0}}" />
</Window>
<Window Type="TaharezLook/StaticText" Name="GP_Quality_Title" >
<Property Name="Text" Value="Graphics Quality:" />
<Property Name="FrameEnabled" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.026855,0},{0.059756,0},{0.382212,0},{0.172922,0}}" />
</Window>
<Window Type="TaharezLook/RadioButton" Name="GP_Quality_High" >
<Property Name="Font" Value="Commonwealth-10" />
<Property Name="Text" Value="High" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.390105,0},{0.283809,0},{0.640107,0},{0.391026,0}}" />
</Window>
<Window Type="TaharezLook/RadioButton" Name="GP_Quality_Ultra" >
<Property Name="Font" Value="Commonwealth-10" />
<Property Name="Text" Value="Ultra" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.390105,0},{0.402362,0},{0.640107,0},{0.509579,0}}" />
</Window>
<Window Type="TaharezLook/StaticText" Name="GP_ScreenMode_Title" >
<Property Name="Font" Value="Commonwealth-10" />
<Property Name="Text" Value="Screen mode:" />
<Property Name="FrameEnabled" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.018046,0},{0.547747,0},{0.373403,0},{0.660913,0}}" />
</Window>
<Window Type="TaharezLook/RadioButton" Name="GP_ScreenMode_Full" >
<Property Name="Font" Value="Commonwealth-10" />
<Property Name="Text" Value="Full screen" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.390105,0},{0.558627,0},{0.640106,0},{0.645021,0}}" />
</Window>
<Window Type="TaharezLook/RadioButton" Name="GP_ScreenMode_Window" >
<Property Name="Font" Value="Commonwealth-10" />
<Property Name="Text" Value="Window" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.390105,0},{0.661317,0},{0.640105,0},{0.747712,0}}" />
</Window>
</Window>
<Window Type="DefaultWindow" Name="GP_Sound//Tab 3" >
<Property Name="Text" Value="Sound" />
<Property Name="Visible" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{-0.0018309,0},{0.00328876,0},{0.998169,0},{1.00329,0}}" />
<Window Type="TaharezLook/Slider" Name="GP_Sound_Volume" >
<Property Name="CurrentValue" Value="0" />
<Property Name="MaximumValue" Value="1" />
<Property Name="ClickStepSize" Value="0.01" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.195639,0},{0.0993839,0},{0.213115,0},{0.642087,0}}" />
</Window>
<Window Type="TaharezLook/Checkbox" Name="GP_Sound_Mute" >
<Property Name="Text" Value="Mute sounds" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.0484677,0},{0.765055,0},{0.298468,0},{0.890081,0}}" />
</Window>
<Window Type="TaharezLook/StaticText" Name="GP_Sound//Tab 3/" >
<Property Name="Text" Value="Volume:" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.0386143,0},{0.276362,0},{0.171437,0},{0.414545,0}}" />
</Window>
</Window>
<Window Type="DefaultWindow" Name="GP_Help//Tab 4" >
<Property Name="Text" Value="?" />
<Property Name="Visible" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.007833,0},{0.004263,0},{0.994474,0},{0.995351,0}}" />
</Window>
</Window>
</Window>
</Window>
</GUILayout>
We are loading the layout as usual, and the tab buttons become active as I hover with the mouse on them. For some reason when I click them the tab doesn't change.
Thanks!
Shlomi.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi Eddie,
Thanks for testing the layout.
We do inject mouse events into CEGUI. I can even see that the tab button is clicked but the tab does not get changed. Does it require any handling on my side or the TabControl should handle the tab swap?
Do you have an idea for what's going on?
Thanks,
Shlomi.
Thanks for testing the layout.
We do inject mouse events into CEGUI. I can even see that the tab button is clicked but the tab does not get changed. Does it require any handling on my side or the TabControl should handle the tab swap?
Do you have an idea for what's going on?
Thanks,
Shlomi.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
No, it should all happen automatically.
The only thing that came to mind was forgetting to inject some of the required inputs. For example, if you inject mouse button down events the button will appear to 'push', but if you're not also injecting mouse button up events, the final stage of the process (i.e. the actual button 'click') will not occur, and nothing will happen.
If you're definitely injecting up and down mouse button events, I have no other ideas at the moment. You could post the code for the injections if you like, so we can make sure you've not missed something
CE.
Does it require any handling on my side or the TabControl should handle the tab swap?
No, it should all happen automatically.
Do you have an idea for what's going on?
The only thing that came to mind was forgetting to inject some of the required inputs. For example, if you inject mouse button down events the button will appear to 'push', but if you're not also injecting mouse button up events, the final stage of the process (i.e. the actual button 'click') will not occur, and nothing will happen.
If you're definitely injecting up and down mouse button events, I have no other ideas at the moment. You could post the code for the injections if you like, so we can make sure you've not missed something

CE.
Who is online
Users browsing this forum: No registered users and 4 guests