Merge pull request #734 from TwilitRealm/number-button-fix

Number Button Fix
This commit is contained in:
TakaRikka
2026-05-09 04:40:55 -07:00
committed by GitHub
3 changed files with 8 additions and 7 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ void NumberButton::set_value(Rml::String value) {
}
bool NumberButton::handle_nav_command(NavCommand cmd) {
if (cmd == NavCommand::Left || cmd == NavCommand::Right) {
if (!is_editing() && (cmd == NavCommand::Left || cmd == NavCommand::Right)) {
const int newValue = std::clamp(
mGetValue() + (cmd == NavCommand::Right ? mStep : -mStep), mMin, mMax);
if (newValue != mGetValue()) {
@@ -66,4 +66,4 @@ bool NumberButton::handle_nav_command(NavCommand cmd) {
return BaseStringButton::handle_nav_command(cmd);
}
} // namespace dusk::ui
} // namespace dusk::ui
+5 -5
View File
@@ -24,7 +24,7 @@ void BaseStringButton::update() {
}
void BaseStringButton::start_editing() {
if (mInputElem != nullptr) {
if (is_editing()) {
return;
}
@@ -79,14 +79,14 @@ void BaseStringButton::request_stop_editing(bool commit, bool refocusRoot) {
bool BaseStringButton::handle_nav_command(NavCommand cmd) {
if (cmd == NavCommand::Confirm) {
if (mInputElem == nullptr) {
if (!is_editing()) {
start_editing();
} else {
request_stop_editing(true, true);
}
return true;
} else if (cmd == NavCommand::Cancel) {
if (mInputElem != nullptr) {
if (is_editing()) {
request_stop_editing(false, true);
return true;
}
@@ -95,7 +95,7 @@ bool BaseStringButton::handle_nav_command(NavCommand cmd) {
}
void BaseStringButton::focus_input() {
if (mInputElem == nullptr) {
if (!is_editing()) {
return;
}
@@ -111,7 +111,7 @@ void BaseStringButton::focus_input() {
void BaseStringButton::stop_editing(bool commit, bool refocusRoot) {
mPendingStopEditing = false;
mPendingInputFocusFrames = 0;
if (mInputElem == nullptr) {
if (!is_editing()) {
return;
}
if (commit) {
+1
View File
@@ -20,6 +20,7 @@ public:
void request_stop_editing(bool commit, bool refocusRoot);
protected:
bool is_editing() { return mInputElem != nullptr; }
bool handle_nav_command(NavCommand cmd) override;
virtual void set_value(Rml::String value) = 0;
virtual Rml::String input_value() { return format_value(); }