diff --git a/Source/Core/Elements/WidgetTextInput.cpp b/Source/Core/Elements/WidgetTextInput.cpp index 04d818b2f..26d91cac0 100644 --- a/Source/Core/Elements/WidgetTextInput.cpp +++ b/Source/Core/Elements/WidgetTextInput.cpp @@ -246,7 +246,7 @@ void WidgetTextInput::Select() void WidgetTextInput::SetSelectionRange(int selection_start, int selection_end) { - if (parent->GetContext()->GetFocusElement() != parent) + if (!IsFocused()) return; const String& value = GetValue(); @@ -382,6 +382,11 @@ Element* WidgetTextInput::GetElement() const return parent; } +bool WidgetTextInput::IsFocused() const +{ + return cursor_timer > 0; +} + void WidgetTextInput::DispatchChangeEvent(bool linebreak) { Dictionary parameters; diff --git a/Source/Core/Elements/WidgetTextInput.h b/Source/Core/Elements/WidgetTextInput.h index d4bb9664c..6fdf8d2b3 100644 --- a/Source/Core/Elements/WidgetTextInput.h +++ b/Source/Core/Elements/WidgetTextInput.h @@ -121,6 +121,9 @@ class WidgetTextInput : public EventListener { /// Gets the parent element containing the widget. Element* GetElement() const; + /// Returns true if the text input element is currently focused. + bool IsFocused() const; + /// Dispatches a change event to the widget's element. void DispatchChangeEvent(bool linebreak = false);