LordDarken
05-11-2014 23:03:06
Hi,
I'm new with myGui and I'm trying to add a layout in my project.
My aim is to do the same thing that I can see in the Demo_Console.
I added this layout:
The code is initally created from the "code generator" in the" layout editor"
I can see the widget and I can add events for subwidgets
. The only problem is when I try to add events for the root widget.
I want to use the close button. But in the ControlsConfigurationPanel constructor, I've got an exception in MyGUI_DelegateImplement.h file:
iter is'nt well initialised.
I add the event like this
Here the main widget header:
And the cpp
I don't see what I'm missing
please help
I'm new with myGui and I'm trying to add a layout in my project.
My aim is to do the same thing that I can see in the Demo_Console.
I added this layout:
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout" version="3.2.0">
<Widget type="Window" skin="WindowCSX" position="175 115 420 540" layer="Overlapped" name="_Main">
<Property key="Movable" value="true"/>
<Property key="MinSize" value="370 360"/>
<Property key="Caption" value="Controls configuration"/>
<Property key="Enabled" value="true"/>
<Property key="Visible" value="true"/>
<Widget type="ListBox" skin="ListBox" position="0 0 185 480" align="Left VStretch" name="actionsList">
<Property key="InheritsPick" value="true"/>
<Property key="AddItem" value="Action 1"/>
<Property key="AddItem" value="Action 2"/>
</Widget>
<Widget type="ListBox" skin="ListBox" position="180 0 230 480" align="Stretch" name="ControlsList">
<Property key="AddItem" value="Ctrl+M / A"/>
<Property key="AddItem" value="Ctrl / Mouse 1"/>
</Widget>
<Widget type="EditBox" skin="EditBox" position="180 480 120 25" align="Right Bottom" name="EditBox">
<Property key="MultiLine" value="false"/>
<Property key="WordWrap" value="true"/>
<Property key="TabPrinting" value="false"/>
<Property key="OverflowToTheLeft" value="false"/>
<Property key="MaxTextLength" value="10"/>
</Widget>
<Widget type="Button" skin="Button" position="300 480 110 25" align="Right Bottom" name="SaveLoadButton">
<Property key="Caption" value="Save/Load"/>
</Widget>
<Widget type="ComboBox" skin="ComboBox" position="0 480 130 25" align="Left Bottom" name="ComboBox">
<Property key="ReadOnly" value="true"/>
<Property key="AddItem" value="default"/>
<Property key="AddItem" value="test"/>
<Property key="Static" value="true"/>
<Property key="TabPrinting" value="false"/>
</Widget>
</Widget>
<CodeGeneratorSettings>
<Property key="IncludeDirectory" value=""/>
<Property key="PanelName" value="ControlsConfigurationPanel"/>
<Property key="PanelNamespace" value="OptionGui"/>
<Property key="SourceDirectory" value=""/>
</CodeGeneratorSettings>
</MyGUI>
The code is initally created from the "code generator" in the" layout editor"
I can see the widget and I can add events for subwidgets

I want to use the close button. But in the ControlsConfigurationPanel constructor, I've got an exception in MyGUI_DelegateImplement.h file:
for (ListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter);
iter is'nt well initialised.
I add the event like this
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false);
if (window != nullptr) window->eventWindowButtonPressed += MyGUI::newDelegate(this, &ControlsConfigurationPanel::notifyWindowButtonPressed);
Here the main widget header:
#ifndef _CONTROLS_CONFIGURATION_PANEL_H_
#define _CONTROLS_CONFIGURATION_PANEL_H_
#include "BaseLayout/BaseLayout.h"
namespace OptionGui
{
ATTRIBUTE_CLASS_LAYOUT(ControlsConfigurationPanel, "ControlsMenu.layout");
class ControlsConfigurationPanel :
public wraps::BaseLayout
{
public:
ControlsConfigurationPanel(MyGUI::Widget* _parent = nullptr);
virtual ~ControlsConfigurationPanel();
private:
//%LE Widget_Declaration list start
ATTRIBUTE_FIELD_WIDGET_NAME(ControlsConfigurationPanel, mactionsListListBox, "actionsList");
MyGUI::ListBox* mactionsListListBox;
ATTRIBUTE_FIELD_WIDGET_NAME(ControlsConfigurationPanel, mControlsListListBox, "ControlsList");
MyGUI::ListBox* mControlsListListBox;
ATTRIBUTE_FIELD_WIDGET_NAME(ControlsConfigurationPanel, mEditBoxEditBox, "EditBox");
MyGUI::EditBox* mEditBoxEditBox;
ATTRIBUTE_FIELD_WIDGET_NAME(ControlsConfigurationPanel, mSaveLoadButtonButton, "SaveLoadButton");
MyGUI::Button* mSaveLoadButtonButton;
ATTRIBUTE_FIELD_WIDGET_NAME(ControlsConfigurationPanel, mComboBoxComboBox, "ComboBox");
MyGUI::ComboBox* mComboBoxComboBox;
//%LE Widget_Declaration list end
void notifyWindowButtonPressedTest(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
void notifyWindowButtonPressed(MyGUI::Window* _sender, const std::string& _button);
};
} // namespace OptionGui
#endif // _CONTROLS_CONFIGURATION_PANEL_H_
And the cpp
#include "ControlsConfigurationPanel.h"
namespace OptionGui
{
ControlsConfigurationPanel::ControlsConfigurationPanel(MyGUI::Widget* _parent)
{
initialiseByAttributes(this, _parent);
mSaveLoadButtonButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &ControlsConfigurationPanel::notifyWindowButtonPressedTest);//ok
MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false);
if (window != nullptr) window->eventWindowButtonPressed += MyGUI::newDelegate(this, &ControlsConfigurationPanel::notifyWindowButtonPressed);
}
ControlsConfigurationPanel::~ControlsConfigurationPanel()
{
}
void ControlsConfigurationPanel::notifyWindowButtonPressedTest(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
{
//if (_button == "close")
//{
mMainWidget->setVisible(false);
//}
}
void ControlsConfigurationPanel::notifyWindowButtonPressed(MyGUI::Window* _sender, const std::string& _button)
{
if (_button == "close")
{
mMainWidget->setVisible(false);
}
}
} // OptionGui
I don't see what I'm missing
