Release selection when the label component loses focus

This commit is contained in:
Simon Robertshaw 2012-06-26 21:05:57 +01:00
parent ab6fed71d7
commit 7c259c0123
2 changed files with 12 additions and 0 deletions

View File

@ -121,6 +121,17 @@ void Label::OnMouseMoved(int localx, int localy, int dx, int dy)
}
}
void Label::Tick(float dt)
{
if(!this->IsFocused() && (selecting || (selectionIndex0 != -1 && selectionIndex1 != -1)))
{
selecting = false;
selectionIndex0 = -1;
selectionIndex1 = -1;
updateSelection();
}
}
void Label::updateSelection()
{
std::string currentText;

View File

@ -51,6 +51,7 @@ namespace ui
virtual void OnMouseUp(int x, int y, unsigned button);
virtual void OnMouseMoved(int localx, int localy, int dx, int dy);
virtual void Draw(const Point& screenPos);
virtual void Tick(float dt);
};
}