minor refactor
This commit is contained in:
parent
636ea2666f
commit
9c31c6c8b7
@ -514,10 +514,7 @@ void TextBox::keyPressed(int key) {
|
||||
// Select/deselect all
|
||||
if (key == keycode::A) {
|
||||
if (selectionStart == selectionEnd) {
|
||||
selectionStart = 0;
|
||||
selectionEnd = input.length();
|
||||
selectionOrigin = 0;
|
||||
setCaret(selectionEnd);
|
||||
select(0, input.length());
|
||||
} else {
|
||||
resetSelection();
|
||||
}
|
||||
@ -525,6 +522,19 @@ void TextBox::keyPressed(int key) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::select(int start, int end) {
|
||||
if (end < start) {
|
||||
std::swap(start, end);
|
||||
}
|
||||
start = normalizeIndex(start);
|
||||
end = normalizeIndex(end);
|
||||
|
||||
selectionStart = start;
|
||||
selectionEnd = end;
|
||||
selectionOrigin = start;
|
||||
setCaret(selectionEnd);
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> TextBox::getAt(glm::vec2 pos, std::shared_ptr<UINode> self) {
|
||||
return UINode::getAt(pos, self);
|
||||
}
|
||||
|
||||
@ -157,6 +157,7 @@ namespace gui {
|
||||
virtual std::wstring getSelection() const;
|
||||
virtual uint getCaret() const;
|
||||
virtual void setCaret(uint position);
|
||||
virtual void select(int start, int end);
|
||||
virtual bool validate();
|
||||
virtual void setValid(bool valid);
|
||||
virtual bool isValid() const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user