Added: onclick_r and onover Lua reflect properties. Setup id to buttonGroup to access it

--HG--
branch : compatibility-develop
hg/compatibility-develop
ulukyn 7 years ago
parent 7a4a59a816
commit d2d1062127

@ -124,9 +124,11 @@ namespace NLGUI
// Event part // Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); } void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; } void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; }
void setActionOnOver (const std::string &actionHandlerName) { _AHOnOver = CAHManager::getInstance()->getAH(actionHandlerName, _AHOverParams); }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); } void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); } void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; } void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
void setParamsOnOver (const std::string &paramsHandlerName) { _AHOverParams = paramsHandlerName; }
void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; } void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; }
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; } void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
@ -141,14 +143,16 @@ namespace NLGUI
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; } IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; } IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; } IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
std::string _getParamsOnOver() const{ return _AHOverParams.toString(); } std::string _getParamsOnOver() const{ return _AHOverParams.toString(); }
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); } std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
std::string _getParamsOnRightClick () const { return _AHRightClickParams.toString(); }
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; } const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; } const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; } const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
// run action on left click // run action on left click
void runLeftClickAction(); void runLeftClickAction();
void runRightClickAction();
// Context menu accessor/ One for each button // Context menu accessor/ One for each button
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; } void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
@ -161,6 +165,7 @@ namespace NLGUI
int luaRunLeftClickAction(CLuaState &ls); int luaRunLeftClickAction(CLuaState &ls);
int luaRunRightClickAction(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase) REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
REFLECT_BOOL("pushed", getPushed, setPushed); REFLECT_BOOL("pushed", getPushed, setPushed);
REFLECT_STRING("col_normal", getColorAsString, setColorAsString); REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
@ -174,6 +179,11 @@ namespace NLGUI
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick); REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick); REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction); REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_STRING("onclick_r", _getActionOnRightClick, setActionOnRightClick);
REFLECT_STRING("params_r", _getParamsOnRightClick, setParamsOnRightClick);
REFLECT_LUA_METHOD("runRightClickAction", luaRunRightClickAction);
REFLECT_STRING("onover", _getActionOnOver, setActionOnOver);
REFLECT_STRING("params_over", _getParamsOnOver, setParamsOnOver);
REFLECT_EXPORT_END REFLECT_EXPORT_END
protected: protected:

@ -996,5 +996,27 @@ namespace NLGUI
return 0; return 0;
} }
// ***************************************************************************
void CCtrlBaseButton::runRightClickAction()
{
if(_AHOnRightClick != NULL)
{
CAHManager::getInstance()->submitEvent( "button_click:" + getId() );
CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams);
}
}
// ***************************************************************************
int CCtrlBaseButton::luaRunRightClickAction(CLuaState &ls)
{
const char *funcName = "onRightClick";
CLuaIHM::checkArgCount(ls, funcName, 0);
runRightClickAction();
return 0;
}
} }

@ -4356,7 +4356,8 @@ namespace NLGUI
CInterfaceGroup *buttonGroup = CWidgetManager::getInstance()->getParser()->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); CInterfaceGroup *buttonGroup = CWidgetManager::getInstance()->getParser()->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams);
if (buttonGroup) if (buttonGroup)
{ {
if (!_AnchorName.empty())
buttonGroup->setId(_AnchorName.back());
// Add the ctrl button // Add the ctrl button
CCtrlTextButton *ctrlButton = dynamic_cast<CCtrlTextButton*>(buttonGroup->getCtrl("button")); CCtrlTextButton *ctrlButton = dynamic_cast<CCtrlTextButton*>(buttonGroup->getCtrl("button"));
if (!ctrlButton) ctrlButton = dynamic_cast<CCtrlTextButton*>(buttonGroup->getCtrl("b")); if (!ctrlButton) ctrlButton = dynamic_cast<CCtrlTextButton*>(buttonGroup->getCtrl("b"));
@ -5830,7 +5831,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
int CGroupHTML::luaSetBackground(CLuaState &ls) int CGroupHTML::luaSetBackground(CLuaState &ls)
{ {
const char *funcName = "renderHtml"; const char *funcName = "setBackground";
CLuaIHM::checkArgCount(ls, funcName, 3); CLuaIHM::checkArgCount(ls, funcName, 3);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN);

Loading…
Cancel
Save