From 7eb41c73e9ecd04e43c7017295c712f2425a3a61 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sat, 8 Feb 2014 18:58:28 -0300 Subject: [PATCH] IntEntry: select all text when the value is changed with the slider --- src/ui/entry.cpp | 5 +++++ src/ui/entry.h | 1 + src/ui/int_entry.cpp | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index 0b1fe70de..18e3a2d87 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -144,6 +144,11 @@ void Entry::selectText(int from, int to) invalidate(); } +void Entry::selectAllText() +{ + selectText(0, -1); +} + void Entry::deselectText() { m_select = -1; diff --git a/src/ui/entry.h b/src/ui/entry.h index 3c19d8c4f..0064eeb20 100644 --- a/src/ui/entry.h +++ b/src/ui/entry.h @@ -32,6 +32,7 @@ namespace ui { void setCaretPos(int pos); void selectText(int from, int to); + void selectAllText(); void deselectText(); void setSuffix(const std::string& suffix); diff --git a/src/ui/int_entry.cpp b/src/ui/int_entry.cpp index 6cdd512fa..d45c1c535 100644 --- a/src/ui/int_entry.cpp +++ b/src/ui/int_entry.cpp @@ -80,8 +80,10 @@ bool IntEntry::onProcessMessage(Message* msg) int oldValue = getValue(); int newValue = oldValue + jmouse_z(0) - jmouse_z(1); newValue = MID(m_min, newValue, m_max); - if (newValue != oldValue) + if (newValue != oldValue) { setValue(newValue); + selectAllText(); + } return true; } break; @@ -139,6 +141,7 @@ void IntEntry::closePopup() void IntEntry::onChangeSlider() { setValue(m_slider->getValue()); + selectAllText(); } } // namespace ui