mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fix for setting and removing focus when using mouse.
- Ensure focus is always sent up the chain of subviews. - Ensure that removed focus is sent down the chain of subviews.
This commit is contained in:
@@ -728,8 +728,15 @@ namespace Terminal.Gui {
|
||||
if (base.HasFocus != value)
|
||||
SetNeedsDisplay ();
|
||||
base.HasFocus = value;
|
||||
|
||||
// Remove focus down the chain of subviews if focus is removed
|
||||
if (value == false && focused != null) {
|
||||
focused.HasFocus = false;
|
||||
focused = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the currently focused view inside this view, or null if nothing is focused.
|
||||
/// </summary>
|
||||
@@ -847,9 +854,13 @@ namespace Terminal.Gui {
|
||||
|
||||
if (focused != null)
|
||||
focused.HasFocus = false;
|
||||
|
||||
focused = view;
|
||||
focused.HasFocus = true;
|
||||
focused.EnsureFocus ();
|
||||
|
||||
// Send focus upwards
|
||||
SuperView?.SetFocus(this);
|
||||
}
|
||||
|
||||
/// <param name="keyEvent">Contains the details about the key that produced the event.</param>
|
||||
@@ -1752,7 +1763,7 @@ namespace Terminal.Gui {
|
||||
if (view != null) {
|
||||
if (!view.WantMousePositionReports && me.Flags == MouseFlags.ReportMousePosition)
|
||||
return;
|
||||
|
||||
|
||||
var nme = new MouseEvent () {
|
||||
X = rx,
|
||||
Y = ry,
|
||||
|
||||
Reference in New Issue
Block a user