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