mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Preserve selection when focusing SpinBox
This commit is contained in:
parent
fa226ade2a
commit
1a98244aac
@ -1400,6 +1400,26 @@ void LineEdit::set_text(String p_text) {
|
||||
scroll_offset = 0;
|
||||
}
|
||||
|
||||
void LineEdit::set_text_with_selection(const String &p_text) {
|
||||
Selection selection_copy = selection;
|
||||
|
||||
clear_internal();
|
||||
append_at_cursor(p_text);
|
||||
_create_undo_state();
|
||||
|
||||
if (expand_to_text_length) {
|
||||
minimum_size_changed();
|
||||
}
|
||||
|
||||
int tlen = text.length();
|
||||
selection = selection_copy;
|
||||
selection.begin = MIN(selection.begin, tlen);
|
||||
selection.end = MIN(selection.end, tlen);
|
||||
selection.cursor_start = MIN(selection.cursor_start, tlen);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void LineEdit::clear() {
|
||||
clear_internal();
|
||||
_text_changed();
|
||||
|
@ -210,6 +210,7 @@ public:
|
||||
void delete_char();
|
||||
void delete_text(int p_from_column, int p_to_column);
|
||||
void set_text(String p_text);
|
||||
void set_text_with_selection(const String &p_text); // Set text, while preserving selection.
|
||||
String get_text() const;
|
||||
void set_placeholder(String p_text);
|
||||
String get_placeholder() const;
|
||||
|
@ -54,7 +54,7 @@ void SpinBox::_value_changed(double) {
|
||||
}
|
||||
}
|
||||
|
||||
line_edit->set_text(value);
|
||||
line_edit->set_text_with_selection(value);
|
||||
}
|
||||
|
||||
void SpinBox::_text_entered(const String &p_string) {
|
||||
|
Loading…
Reference in New Issue
Block a user