diff options
author | crupest <crupest@outlook.com> | 2018-10-07 00:49:38 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-10-07 00:49:38 +0800 |
commit | 36820c22929f4fb11892c4fbd52f321cc63a55ad (patch) | |
tree | 0c87a377fac3d9359995cb1fa62ec541fe83f579 /src/ui/controls/text_control.cpp | |
parent | b0057dc911f96258c7280b89c8f4da828ecc283c (diff) | |
download | cru-36820c22929f4fb11892c4fbd52f321cc63a55ad.tar.gz cru-36820c22929f4fb11892c4fbd52f321cc63a55ad.tar.bz2 cru-36820c22929f4fb11892c4fbd52f321cc63a55ad.zip |
Add shift selection, and fix the bug that caret is at wrong position when move with selection.
Diffstat (limited to 'src/ui/controls/text_control.cpp')
-rw-r--r-- | src/ui/controls/text_control.cpp | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/ui/controls/text_control.cpp b/src/ui/controls/text_control.cpp index ee5b253d..3c5d7c33 100644 --- a/src/ui/controls/text_control.cpp +++ b/src/ui/controls/text_control.cpp @@ -162,18 +162,7 @@ namespace cru::ui::controls { const auto hit_test_result = TextLayoutHitTest(text_layout_.Get(), args.GetPoint(this), false).value(); RequestChangeCaretPosition(hit_test_result); - if (hit_test_result > mouse_down_position_) - { - selected_range_ = TextRange(mouse_down_position_, hit_test_result - mouse_down_position_); - } - else if (hit_test_result < mouse_down_position_) - { - selected_range_ = TextRange(hit_test_result, mouse_down_position_ - hit_test_result); - } - else - { - selected_range_ = std::nullopt; - } + selected_range_ = TextRange::FromTwoSides(hit_test_result, mouse_down_position_); Repaint(); } } |