mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-22 17:48:01 +02:00
Slightly better handling of clicking within a selection
This commit is contained in:
parent
394a7e0bc5
commit
6d12b42456
1 changed files with 21 additions and 14 deletions
|
@ -751,11 +751,21 @@ namespace Beefy.widgets
|
|||
|
||||
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
|
||||
{
|
||||
bool hadSelection = HasSelection();
|
||||
|
||||
base.MouseDown(x, y, btn, btnCount);
|
||||
mEditWidget.SetFocus();
|
||||
|
||||
if (HasSelection())
|
||||
{
|
||||
GetLineCharAtCoord(x, y, var line, var lineChar, ?);
|
||||
int textPos = GetTextIdx(line, lineChar);
|
||||
if ((textPos > mSelection.Value.MinPos) && (textPos < mSelection.Value.MaxPos))
|
||||
{
|
||||
// Leave selection
|
||||
mDragSelectionKind = .ClickedInside;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mSelection == null) && (mWidgetWindow.IsKeyDown(KeyCode.Shift)))
|
||||
StartSelection();
|
||||
|
||||
|
@ -809,15 +819,6 @@ namespace Beefy.widgets
|
|||
}
|
||||
else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift))
|
||||
{
|
||||
if ((mSelection != null) && (CursorTextPos > mSelection.Value.MinPos) && (CursorTextPos < mSelection.Value.MaxPos))
|
||||
{
|
||||
if (hadSelection)
|
||||
{
|
||||
// Leave selection
|
||||
mDragSelectionKind = .ClickedInside;
|
||||
}
|
||||
}
|
||||
else
|
||||
StartSelection();
|
||||
}
|
||||
else
|
||||
|
@ -832,7 +833,10 @@ namespace Beefy.widgets
|
|||
{
|
||||
mDragSelectionUnion = null;
|
||||
if ((mDragSelectionKind == .ClickedInside) && (btn == 0))
|
||||
{
|
||||
mSelection = null;
|
||||
MoveCursorToCoord(x, y);
|
||||
}
|
||||
mDragSelectionKind = .None;
|
||||
}
|
||||
}
|
||||
|
@ -843,12 +847,15 @@ namespace Beefy.widgets
|
|||
|
||||
if ((mMouseDown) && (mMouseFlags == .Left))
|
||||
{
|
||||
if (mDragSelectionKind == .ClickedInside)
|
||||
mDragSelectionKind = .DraggingInside;
|
||||
if (mDragSelectionKind == .DraggingInside)
|
||||
return;
|
||||
|
||||
MoveCursorToCoord(x, y);
|
||||
ClampCursor();
|
||||
if (mDragSelectionKind == .Dragging)
|
||||
SelectToCursor();
|
||||
else if (mDragSelectionKind == .ClickedInside)
|
||||
mDragSelectionKind = .DraggingInside;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue