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)
|
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
|
||||||
{
|
{
|
||||||
bool hadSelection = HasSelection();
|
|
||||||
|
|
||||||
base.MouseDown(x, y, btn, btnCount);
|
base.MouseDown(x, y, btn, btnCount);
|
||||||
mEditWidget.SetFocus();
|
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)))
|
if ((mSelection == null) && (mWidgetWindow.IsKeyDown(KeyCode.Shift)))
|
||||||
StartSelection();
|
StartSelection();
|
||||||
|
|
||||||
|
@ -809,16 +819,7 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift))
|
else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift))
|
||||||
{
|
{
|
||||||
if ((mSelection != null) && (CursorTextPos > mSelection.Value.MinPos) && (CursorTextPos < mSelection.Value.MaxPos))
|
StartSelection();
|
||||||
{
|
|
||||||
if (hadSelection)
|
|
||||||
{
|
|
||||||
// Leave selection
|
|
||||||
mDragSelectionKind = .ClickedInside;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
StartSelection();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SelectToCursor();
|
SelectToCursor();
|
||||||
|
@ -832,7 +833,10 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
mDragSelectionUnion = null;
|
mDragSelectionUnion = null;
|
||||||
if ((mDragSelectionKind == .ClickedInside) && (btn == 0))
|
if ((mDragSelectionKind == .ClickedInside) && (btn == 0))
|
||||||
|
{
|
||||||
mSelection = null;
|
mSelection = null;
|
||||||
|
MoveCursorToCoord(x, y);
|
||||||
|
}
|
||||||
mDragSelectionKind = .None;
|
mDragSelectionKind = .None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,12 +847,15 @@ namespace Beefy.widgets
|
||||||
|
|
||||||
if ((mMouseDown) && (mMouseFlags == .Left))
|
if ((mMouseDown) && (mMouseFlags == .Left))
|
||||||
{
|
{
|
||||||
|
if (mDragSelectionKind == .ClickedInside)
|
||||||
|
mDragSelectionKind = .DraggingInside;
|
||||||
|
if (mDragSelectionKind == .DraggingInside)
|
||||||
|
return;
|
||||||
|
|
||||||
MoveCursorToCoord(x, y);
|
MoveCursorToCoord(x, y);
|
||||||
ClampCursor();
|
ClampCursor();
|
||||||
if (mDragSelectionKind == .Dragging)
|
if (mDragSelectionKind == .Dragging)
|
||||||
SelectToCursor();
|
SelectToCursor();
|
||||||
else if (mDragSelectionKind == .ClickedInside)
|
|
||||||
mDragSelectionKind = .DraggingInside;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue