Prevent Spinbox value update while not focused or disabled

(cherry picked from commit 4df33cbcb3)
This commit is contained in:
volzhs 2016-11-25 03:15:42 +09:00 committed by Rémi Verschelde
parent ef009a8b91
commit 608e3f3097

View File

@ -92,6 +92,9 @@ void SpinBox::_range_click_timeout() {
void SpinBox::_input_event(const InputEvent& p_event) { void SpinBox::_input_event(const InputEvent& p_event) {
if (!is_editable()) {
return;
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) { if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) {
const InputEventMouseButton &mb=p_event.mouse_button; const InputEventMouseButton &mb=p_event.mouse_button;
@ -110,19 +113,24 @@ void SpinBox::_input_event(const InputEvent& p_event) {
range_click_timer->set_one_shot(true); range_click_timer->set_one_shot(true);
range_click_timer->start(); range_click_timer->start();
line_edit->grab_focus();
} break; } break;
case BUTTON_RIGHT: { case BUTTON_RIGHT: {
set_val( (up?get_max():get_min()) ); set_val( (up?get_max():get_min()) );
line_edit->grab_focus();
} break; } break;
case BUTTON_WHEEL_UP: { case BUTTON_WHEEL_UP: {
if (line_edit->has_focus()) {
set_val( get_val() + get_step() ); set_val( get_val() + get_step() );
accept_event();
}
} break; } break;
case BUTTON_WHEEL_DOWN: { case BUTTON_WHEEL_DOWN: {
if (line_edit->has_focus()) {
set_val( get_val() - get_step() ); set_val( get_val() - get_step() );
accept_event();
}
} break; } break;
} }
} }