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>
126 lines
3.1 KiB
C#
126 lines
3.1 KiB
C#
using System;
|
|
|
|
namespace UICatalog.Scenarios;
|
|
|
|
[ScenarioMetadata ("View Experiments", "v2 View Experiments")]
|
|
[ScenarioCategory ("Controls")]
|
|
[ScenarioCategory ("Adornments")]
|
|
[ScenarioCategory ("Layout")]
|
|
[ScenarioCategory ("Proof of Concept")]
|
|
public class ViewExperiments : Scenario
|
|
{
|
|
public override void Main ()
|
|
{
|
|
Application.Init ();
|
|
|
|
Window app = new ()
|
|
{
|
|
Title = GetQuitKeyAndName (),
|
|
TabStop = TabBehavior.TabGroup
|
|
};
|
|
|
|
var editor = new AdornmentsEditor
|
|
{
|
|
X = 0,
|
|
Y = 0,
|
|
TabStop = TabBehavior.NoStop,
|
|
AutoSelectViewToEdit = true,
|
|
ShowViewIdentifier = true
|
|
};
|
|
app.Add (editor);
|
|
|
|
FrameView testFrame = new ()
|
|
{
|
|
Title = "_1 Test Frame",
|
|
X = Pos.Right (editor),
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill (),
|
|
};
|
|
|
|
app.Add (testFrame);
|
|
|
|
Button button = new ()
|
|
{
|
|
X = 0,
|
|
Y = 0,
|
|
Title = $"TopButton _{GetNextHotKey ()}",
|
|
};
|
|
|
|
testFrame.Add (button);
|
|
|
|
button = new ()
|
|
{
|
|
X = Pos.AnchorEnd (),
|
|
Y = Pos.AnchorEnd (),
|
|
Title = $"TopButton _{GetNextHotKey ()}",
|
|
};
|
|
|
|
var popoverView = new View ()
|
|
{
|
|
X = Pos.Center (),
|
|
Y = Pos.Center (),
|
|
Width = 30,
|
|
Height = 10,
|
|
Title = "Popover",
|
|
Text = "This is a popover",
|
|
Visible = false,
|
|
CanFocus = true,
|
|
Arrangement = ViewArrangement.Resizable | ViewArrangement.Movable
|
|
};
|
|
popoverView.BorderStyle = LineStyle.RoundedDotted;
|
|
|
|
Button popoverButton = new ()
|
|
{
|
|
X = Pos.Center (),
|
|
Y = Pos.Center (),
|
|
Title = $"_Close",
|
|
};
|
|
//popoverButton.Accepting += (sender, e) => App?.Popover!.Visible = false;
|
|
popoverView.Add (popoverButton);
|
|
|
|
button.Accepting += ButtonAccepting;
|
|
|
|
void ButtonAccepting (object sender, CommandEventArgs e)
|
|
{
|
|
//App?.Popover = popoverView;
|
|
//App?.Popover!.Visible = true;
|
|
}
|
|
|
|
testFrame.Selecting += (sender, e) =>
|
|
{
|
|
if (e.Context is CommandContext<MouseBinding> { Binding.MouseEventArgs: { } mouseArgs })
|
|
{
|
|
if (mouseArgs.Flags == MouseFlags.Button3Clicked)
|
|
{
|
|
popoverView.X = mouseArgs.ScreenPosition.X;
|
|
popoverView.Y = mouseArgs.ScreenPosition.Y;
|
|
//App?.Popover = popoverView;
|
|
//App?.Popover!.Visible = true;
|
|
}
|
|
}
|
|
};
|
|
|
|
testFrame.Add (button);
|
|
|
|
editor.AutoSelectViewToEdit = true;
|
|
editor.AutoSelectSuperView = testFrame;
|
|
editor.AutoSelectAdornments = true;
|
|
|
|
Application.Run (app);
|
|
popoverView.Dispose ();
|
|
app.Dispose ();
|
|
|
|
Application.Shutdown ();
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
private int _hotkeyCount;
|
|
|
|
private char GetNextHotKey ()
|
|
{
|
|
return (char)((int)'A' + _hotkeyCount++);
|
|
}
|
|
}
|