Fix lineedit selection bug
This commit is contained in:
parent
2f9e286dc7
commit
5c9bf33b0a
3 changed files with 9 additions and 21 deletions
|
|
@ -136,7 +136,6 @@ private:
|
|||
unsigned int blink_timer = 0;
|
||||
int clip_start_offset = 0;
|
||||
int clip_end_offset = 0;
|
||||
bool ignore_mouse_events = false;
|
||||
|
||||
struct UndoInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ bool Widget::IsVisible()
|
|||
void Widget::SetFocus()
|
||||
{
|
||||
Widget* window = Window();
|
||||
if (window)
|
||||
if (window && window->FocusWidget != this)
|
||||
{
|
||||
if (window->FocusWidget)
|
||||
window->FocusWidget->OnLostFocus();
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ void LineEdit::SetSelectAllOnFocusGain(bool enable)
|
|||
|
||||
void LineEdit::OnMouseMove(const Point& pos)
|
||||
{
|
||||
if (mouse_selecting && !ignore_mouse_events)
|
||||
if (mouse_selecting)
|
||||
{
|
||||
if (pos.x < 0.0 || pos.x >= GetWidth())
|
||||
{
|
||||
|
|
@ -331,23 +331,13 @@ bool LineEdit::OnMouseUp(const Point& pos, InputKey key)
|
|||
{
|
||||
if (mouse_selecting && key == InputKey::LeftMouse)
|
||||
{
|
||||
if (ignore_mouse_events) // This prevents text selection from changing from what was set when focus was gained.
|
||||
{
|
||||
ReleasePointerCapture();
|
||||
ignore_mouse_events = false;
|
||||
mouse_selecting = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll_timer->Stop();
|
||||
ReleasePointerCapture();
|
||||
mouse_selecting = false;
|
||||
int sel_end = GetCharacterIndex(pos.x);
|
||||
SetSelectionLength(sel_end - selection_start);
|
||||
cursor_pos = sel_end;
|
||||
SetFocus();
|
||||
Update();
|
||||
}
|
||||
scroll_timer->Stop();
|
||||
ReleasePointerCapture();
|
||||
mouse_selecting = false;
|
||||
int sel_end = GetCharacterIndex(pos.x);
|
||||
SetSelectionLength(sel_end - selection_start);
|
||||
cursor_pos = sel_end;
|
||||
Update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -604,7 +594,6 @@ void LineEdit::OnSetFocus()
|
|||
timer->Start(500);
|
||||
if (select_all_on_focus_gain)
|
||||
SelectAll();
|
||||
ignore_mouse_events = true;
|
||||
cursor_pos = (int)text.length();
|
||||
|
||||
Update();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue