From 7c259c01238d91d41a778003e2529f5c06e09139 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 26 Jun 2012 21:05:57 +0100 Subject: [PATCH] Release selection when the label component loses focus --- src/interface/Label.cpp | 11 +++++++++++ src/interface/Label.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp index 755e3ceb1..a51387848 100644 --- a/src/interface/Label.cpp +++ b/src/interface/Label.cpp @@ -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; diff --git a/src/interface/Label.h b/src/interface/Label.h index e154c0e51..34822bb42 100644 --- a/src/interface/Label.h +++ b/src/interface/Label.h @@ -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); }; }