Skip to content

Commit 9363401

Browse files
committed
Broke OnMouseClicked
1 parent 12fe1c2 commit 9363401

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

Terminal.Gui/Application/Application.Mouse.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ internal static void RaiseMouseEvent (MouseEventArgs mouseEvent)
170170
return;
171171
}
172172

173-
// We can combine this into the switch expression to reduce cognitive complexity even more and likely
174-
// avoid one or two of these checks in the process, as well.
175-
176173
WantContinuousButtonPressedView = deepestViewUnderMouse switch
177174
{
178175
{ WantContinuousButtonPressed: true } => deepestViewUnderMouse,

Terminal.Gui/Input/MouseEventArgs.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ public class MouseEventArgs : HandledEventArgs
2626
/// <summary>The position of the mouse in <see cref="View"/>'s Viewport-relative coordinates. Only valid if <see cref="View"/> is set.</summary>
2727
public Point Position { get; set; }
2828

29+
public bool IsButtonEvent
30+
{
31+
get
32+
{
33+
return Flags.HasFlag (MouseFlags.Button1Clicked)
34+
|| Flags.HasFlag (MouseFlags.Button2Clicked)
35+
|| Flags.HasFlag (MouseFlags.Button3Clicked)
36+
|| Flags.HasFlag (MouseFlags.Button4Clicked)
37+
|| Flags.HasFlag (MouseFlags.Button1DoubleClicked)
38+
|| Flags.HasFlag (MouseFlags.Button2DoubleClicked)
39+
|| Flags.HasFlag (MouseFlags.Button3DoubleClicked)
40+
|| Flags.HasFlag (MouseFlags.Button4DoubleClicked)
41+
|| Flags.HasFlag (MouseFlags.Button1TripleClicked)
42+
|| Flags.HasFlag (MouseFlags.Button2TripleClicked)
43+
|| Flags.HasFlag (MouseFlags.Button3TripleClicked)
44+
|| Flags.HasFlag (MouseFlags.Button4TripleClicked);
45+
}
46+
}
47+
2948
/// <summary>Returns a <see cref="T:System.String"/> that represents the current <see cref="Terminal.Gui.MouseEventArgs"/>.</summary>
3049
/// <returns>A <see cref="T:System.String"/> that represents the current <see cref="Terminal.Gui.MouseEventArgs"/>.</returns>
3150
public override string ToString () { return $"({ScreenPosition}):{Flags}:{View?.Id}:{Position}"; }

Terminal.Gui/View/View.Mouse.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected virtual void OnMouseLeave () { }
201201

202202
/// <summary>Gets or sets whether the <see cref="View"/> wants mouse position reports.</summary>
203203
/// <value><see langword="true"/> if mouse position reports are wanted; otherwise, <see langword="false"/>.</value>
204-
public virtual bool WantMousePositionReports { get; set; }
204+
public bool WantMousePositionReports { get; set; }
205205

206206
/// <summary>
207207
/// Processes a new <see cref="MouseEvent"/>. This method is called by <see cref="Application.RaiseMouseEvent"/> when a mouse
@@ -487,18 +487,18 @@ private bool WhenGrabbedHandlePressed (MouseEventArgs mouseEvent)
487487
|| mouseEvent.Flags.HasFlag (MouseFlags.Button3Pressed)
488488
|| mouseEvent.Flags.HasFlag (MouseFlags.Button4Pressed))
489489
{
490-
bool firstPress = true;
491490
// The first time we get pressed event, grab the mouse and set focus
492491
if (Application.MouseGrabView != this)
493492
{
494-
firstPress = true;
495493
Application.GrabMouse (this);
496494

497495
if (!HasFocus && CanFocus)
498496
{
499497
// Set the focus, but don't invoke Accept
500498
SetFocus ();
501499
}
500+
501+
mouseEvent.Handled = true;
502502
}
503503

504504
if (Viewport.Contains (mouseEvent.Position))
@@ -519,7 +519,7 @@ private bool WhenGrabbedHandlePressed (MouseEventArgs mouseEvent)
519519
}
520520
}
521521

522-
if (!firstPress && WantContinuousButtonPressed && Application.MouseGrabView == this)
522+
if (WantContinuousButtonPressed && Application.MouseGrabView == this)
523523
{
524524
// If this is not the first pressed event, generate a click
525525
return RaiseMouseClickEvent (mouseEvent);

0 commit comments

Comments
 (0)