Added: Right click action handler for menu item

--HG--
branch : feature-closest-landmarks-menu
feature/streamed-package
Nimetu 5 years ago
parent 9fc1987631
commit 4a15779094

@ -136,9 +136,13 @@ namespace NLGUI
void removeLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
const std::string getRightClickHandler(uint lineIndex) const;
const std::string getRightClickHandlerParam(uint lineIndex) const;
void setActionHandler(uint lineIndex, const std::string &ah = "");
void setActionHandlerParam(uint lineIndex, const std::string &params = "");
void setRightClickHandler(uint lineIndex, const std::string &ah = "");
void setRightClickHandlerParam(uint lineIndex, const std::string &params = "");
void openSubMenu (sint32 nb);
@ -235,6 +239,8 @@ namespace NLGUI
CInterfaceGroup *Separator;
std::string AHName;
std::string AHParams;
std::string AHRightClick;
std::string AHRightClickParams;
std::string Id;
std::string Cond; // condition to know if the entry is grayed
CViewBitmap *CheckBox;
@ -332,9 +338,13 @@ namespace NLGUI
void deleteLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
const std::string getRightClickHandler(uint lineIndex) const;
const std::string getRightClickHandlerParam(uint lineIndex) const;
void setActionHandler(uint lineIndex, const std::string &ah = "");
void setActionHandlerParam(uint lineIndex, const std::string &params = "");
void setRightClickHandler(uint lineIndex, const std::string &ah = "");
void setRightClickHandlerParam(uint lineIndex, const std::string &params = "");
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),

@ -1038,6 +1038,18 @@ namespace NLGUI
}
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)
{
// If a line is selected and the line is not grayed and has right click action handler
if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed()) && !_Lines[_Selected].AHRightClick.empty())
{
CAHManager::getInstance()->runActionHandler ( _Lines[_Selected].AHRightClick,
CWidgetManager::getInstance()->getCtrlLaunchingModal(),
_Lines[_Selected].AHRightClickParams );
return true;
}
}
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
@ -1685,6 +1697,28 @@ namespace NLGUI
_Lines[lineIndex].AHParams = params;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setRightClickHandler(uint lineIndex, const std::string &ah)
{
if (lineIndex > _Lines.size())
{
nlwarning("Bad index");
return;
}
_Lines[lineIndex].AHRightClick = ah;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setRightClickHandlerParam(uint lineIndex, const std::string &params)
{
if (lineIndex > _Lines.size())
{
nlwarning("Bad index");
return;
}
_Lines[lineIndex].AHRightClickParams = params;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setSelectable(uint lineIndex, bool selectable)
{
@ -2632,6 +2666,20 @@ namespace NLGUI
_RootMenu->setActionHandlerParam(lineIndex, params);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setRightClickHandler(uint lineIndex, const std::string &ah)
{
if (_RootMenu)
_RootMenu->setRightClickHandler(lineIndex, ah);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setRightClickHandlerParam(uint lineIndex, const std::string &params)
{
if (_RootMenu)
_RootMenu->setRightClickHandlerParam(lineIndex, params);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/)
{

Loading…
Cancel
Save