mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
handle double-click in Town Portal dialog
This commit is contained in:
parent
a19c9eccc4
commit
08b04a3527
@ -284,6 +284,8 @@ void CGuiHandler::handleCurrentEvent()
|
||||
switch(current->button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
{
|
||||
auto doubleClicked = false;
|
||||
if(lastClick == current->motion && (SDL_GetTicks() - lastClickTime) < 300)
|
||||
{
|
||||
std::list<CIntObject*> hlp = doubleClickInterested;
|
||||
@ -293,6 +295,7 @@ void CGuiHandler::handleCurrentEvent()
|
||||
if((*i)->pos.isInside(current->motion.x, current->motion.y))
|
||||
{
|
||||
(*i)->onDoubleClick();
|
||||
doubleClicked = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,8 +304,10 @@ void CGuiHandler::handleCurrentEvent()
|
||||
lastClick = current->motion;
|
||||
lastClickTime = SDL_GetTicks();
|
||||
|
||||
handleMouseButtonClick(lclickable, EIntObjMouseBtnType::LEFT, true);
|
||||
if(!doubleClicked)
|
||||
handleMouseButtonClick(lclickable, EIntObjMouseBtnType::LEFT, true);
|
||||
break;
|
||||
}
|
||||
case SDL_BUTTON_RIGHT:
|
||||
handleMouseButtonClick(rclickable, EIntObjMouseBtnType::RIGHT, true);
|
||||
break;
|
||||
|
@ -2039,7 +2039,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
|
||||
}
|
||||
|
||||
CObjectListWindow::CItem::CItem(CObjectListWindow * _parent, size_t _id, std::string _text)
|
||||
: CIntObject(LCLICK),
|
||||
: CIntObject(LCLICK | DOUBLECLICK),
|
||||
parent(_parent),
|
||||
index(_id)
|
||||
{
|
||||
@ -2069,6 +2069,11 @@ void CObjectListWindow::CItem::clickLeft(tribool down, bool previousState)
|
||||
parent->changeSelection(index);
|
||||
}
|
||||
|
||||
void CObjectListWindow::CItem::onDoubleClick()
|
||||
{
|
||||
parent->elementSelected();
|
||||
}
|
||||
|
||||
CObjectListWindow::CObjectListWindow(const std::vector<int> & _items, std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr, std::function<void(int)> Callback, size_t initialSelection)
|
||||
: CWindowObject(PLAYER_COLORED, "TPGATE"),
|
||||
onSelect(Callback),
|
||||
|
@ -163,6 +163,7 @@ class CObjectListWindow : public CWindowObject
|
||||
|
||||
void select(bool on);
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void onDoubleClick() override;
|
||||
};
|
||||
|
||||
std::function<void(int)> onSelect;//called when OK button is pressed, returns id of selected item.
|
||||
|
Loading…
Reference in New Issue
Block a user