mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* 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:
@@ -60,7 +60,7 @@ public class TreeViewFileSystem : Scenario
|
||||
};
|
||||
|
||||
win.Add (_detailsFrame);
|
||||
_treeViewFiles.MouseClick += TreeViewFiles_MouseClick;
|
||||
_treeViewFiles.Selecting += TreeViewFiles_Selecting;
|
||||
_treeViewFiles.KeyDown += TreeViewFiles_KeyPress;
|
||||
_treeViewFiles.SelectionChanged += TreeViewFiles_SelectionChanged;
|
||||
|
||||
@@ -556,17 +556,23 @@ public class TreeViewFileSystem : Scenario
|
||||
}
|
||||
}
|
||||
|
||||
private void TreeViewFiles_MouseClick (object? sender, MouseEventArgs obj)
|
||||
private void TreeViewFiles_Selecting (object? sender, CommandEventArgs e)
|
||||
{
|
||||
if (_treeViewFiles is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if user right clicks
|
||||
if (obj.Flags.HasFlag (MouseFlags.Button3Clicked))
|
||||
// Only handle mouse clicks
|
||||
if (e.Context is not CommandContext<MouseBinding> { Binding.MouseEventArgs: { } mouseArgs })
|
||||
{
|
||||
IFileSystemInfo? rightClicked = _treeViewFiles.GetObjectOnRow (obj.Position.Y);
|
||||
return;
|
||||
}
|
||||
|
||||
// if user right clicks
|
||||
if (mouseArgs.Flags.HasFlag (MouseFlags.Button3Clicked))
|
||||
{
|
||||
IFileSystemInfo? rightClicked = _treeViewFiles.GetObjectOnRow (mouseArgs.Position.Y);
|
||||
|
||||
// nothing was clicked
|
||||
if (rightClicked is null)
|
||||
@@ -576,8 +582,8 @@ public class TreeViewFileSystem : Scenario
|
||||
|
||||
ShowContextMenu (
|
||||
new (
|
||||
obj.Position.X + _treeViewFiles.Frame.X,
|
||||
obj.Position.Y + _treeViewFiles.Frame.Y + 2
|
||||
mouseArgs.Position.X + _treeViewFiles.Frame.X,
|
||||
mouseArgs.Position.Y + _treeViewFiles.Frame.Y + 2
|
||||
),
|
||||
rightClicked
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user