Fixes #4176. Removes View.MouseClick (#4450)

* Initial plan

* Add comprehensive MouseClick removal analysis

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix code review feedback on analysis document

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Add actual line numbers to analysis document

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Final polish on analysis document - clarify TextView

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Phase 3: Port 6 simple Views from MouseClick to Selecting/MouseBindings

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Phase 2: Port 10 Scenarios from MouseClick to Selecting/remove

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Update analysis document - Phases 2 & 3 complete

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix failing tests - Button multi-button support and Label focus handling

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Phase 4: Port ScrollBar from OnMouseClick to OnSelecting; remove analysis doc

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Phase 5: Update/remove tests that explicitly test MouseClick API

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Code cleanup

* Remove MouseClick event

Consolidated mouse event handling by removing the `MouseClick`
event and integrating its functionality into the `MouseEvent`
event. Simplified `MouseEventArgs` documentation and added
support for invoking commands bound to mouse events.

Reorganized code by removing `Mouse Pressed Events` and
`Mouse Click Events` regions, introducing a new `WhenGrabbed
Handlers` region. Updated tests to replace `MouseClick` with
`MouseEvent`, adjusted test logic, and improved variable
naming for clarity.

Removed redundant assertions and unused code related to
`MouseClick`. Improved event propagation logic to ensure
proper handling of unhandled events. Performed general code
cleanup to enhance readability and maintainability.

* Updated deep dives.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
Copilot
2025-12-06 14:41:20 -07:00
committed by GitHub
parent 0eafb5947e
commit dd12df7fb7
31 changed files with 811 additions and 670 deletions

View File

@@ -128,46 +128,46 @@ public class MouseTests
[Theory]
// click on border
[InlineData (0, 0, 0, 0, 0, false)]
[InlineData (0, 1, 0, 0, 0, false)]
[InlineData (0, 0, 1, 0, 0, false)]
[InlineData (0, 9, 0, 0, 0, false)]
[InlineData (0, 0, 9, 0, 0, false)]
[InlineData (0, 0, 0, 0, 0, 0)]
[InlineData (0, 1, 0, 0, 0, 0)]
[InlineData (0, 0, 1, 0, 0, 0)]
[InlineData (0, 9, 0, 0, 0, 0)]
[InlineData (0, 0, 9, 0, 0, 0)]
// outside border
[InlineData (0, 10, 0, 0, 0, false)]
[InlineData (0, 0, 10, 0, 0, false)]
[InlineData (0, 10, 0, 0, 0, 0)]
[InlineData (0, 0, 10, 0, 0, 0)]
// view is offset from origin ; click is on border
[InlineData (1, 1, 1, 0, 0, false)]
[InlineData (1, 2, 1, 0, 0, false)]
[InlineData (1, 1, 2, 0, 0, false)]
[InlineData (1, 10, 1, 0, 0, false)]
[InlineData (1, 1, 10, 0, 0, false)]
[InlineData (1, 1, 1, 0, 0, 0)]
[InlineData (1, 2, 1, 0, 0, 0)]
[InlineData (1, 1, 2, 0, 0, 0)]
[InlineData (1, 10, 1, 0, 0, 0)]
[InlineData (1, 1, 10, 0, 0, 0)]
// outside border
[InlineData (1, -1, 0, 0, 0, false)]
[InlineData (1, 0, -1, 0, 0, false)]
[InlineData (1, 10, 10, 0, 0, false)]
[InlineData (1, 11, 11, 0, 0, false)]
[InlineData (1, -1, 0, 0, 0, 0)]
[InlineData (1, 0, -1, 0, 0, 0)]
[InlineData (1, 10, 10, 0, 0, 0)]
[InlineData (1, 11, 11, 0, 0, 0)]
// view is at origin, click is inside border
[InlineData (0, 1, 1, 0, 0, true)]
[InlineData (0, 2, 1, 1, 0, true)]
[InlineData (0, 1, 2, 0, 1, true)]
[InlineData (0, 8, 1, 7, 0, true)]
[InlineData (0, 1, 8, 0, 7, true)]
[InlineData (0, 8, 8, 7, 7, true)]
[InlineData (0, 1, 1, 0, 0, 1)]
[InlineData (0, 2, 1, 1, 0, 1)]
[InlineData (0, 1, 2, 0, 1, 1)]
[InlineData (0, 8, 1, 7, 0, 1)]
[InlineData (0, 1, 8, 0, 7, 1)]
[InlineData (0, 8, 8, 7, 7, 1)]
// view is offset from origin ; click inside border
// our view is 10x10, but has a border, so it's bounds is 8x8
[InlineData (1, 2, 2, 0, 0, true)]
[InlineData (1, 3, 2, 1, 0, true)]
[InlineData (1, 2, 3, 0, 1, true)]
[InlineData (1, 9, 2, 7, 0, true)]
[InlineData (1, 2, 9, 0, 7, true)]
[InlineData (1, 9, 9, 7, 7, true)]
[InlineData (1, 10, 10, 7, 7, false)]
[InlineData (1, 2, 2, 0, 0, 1)]
[InlineData (1, 3, 2, 1, 0, 1)]
[InlineData (1, 2, 3, 0, 1, 1)]
[InlineData (1, 9, 2, 7, 0, 1)]
[InlineData (1, 2, 9, 0, 7, 1)]
[InlineData (1, 9, 9, 7, 7, 1)]
[InlineData (1, 10, 10, 7, 7, 0)]
//01234567890123456789
// |12345678|
@@ -178,13 +178,13 @@ public class MouseTests
int clickY,
int expectedX,
int expectedY,
bool expectedClicked
int expectedClickedCount
)
{
Size size = new (10, 10);
Point pos = new (offset, offset);
var clicked = false;
int clickedCount = 0;
using IApplication? application = Application.Create ();
@@ -208,14 +208,14 @@ public class MouseTests
var mouseEvent = new MouseEventArgs { Position = new (clickX, clickY), ScreenPosition = new (clickX, clickY), Flags = MouseFlags.Button1Clicked };
view.MouseClick += (s, e) =>
view.MouseEvent += (_s, e) =>
{
Assert.Equal (expectedX, e.Position.X);
Assert.Equal (expectedY, e.Position.Y);
clicked = true;
clickedCount += e.IsSingleDoubleOrTripleClicked ? 1 : 0;
};
application.Mouse.RaiseMouseEvent (mouseEvent);
Assert.Equal (expectedClicked, clicked);
Assert.Equal (expectedClickedCount, clickedCount);
}
}