From 2e2566f0f0eead812bc4da5c55563374ffb391bf Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 13 Jun 2022 23:48:23 +0100 Subject: [PATCH] Fixes #1796. If TextView is ReadOnly tab and return are ignored. Also fixes Button click via spacebar (#1804) * Fixes #1796. If TextView is read only allows tab around and return. * Fixes space bar responding on Button. --- Terminal.Gui/Views/Button.cs | 2 +- Terminal.Gui/Views/TextView.cs | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index ca204fa13..69cd4c648 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -159,7 +159,7 @@ namespace Terminal.Gui { set { if (hotKey != value) { var v = value == Key.Unknown ? Key.Null : value; - if (ContainsKeyBinding (Key.Space | hotKey)) { + if (hotKey != Key.Null && ContainsKeyBinding (Key.Space | hotKey)) { if (v == Key.Null) { ClearKeybinding (Key.Space | hotKey); } else { diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 959ab4def..cde610256 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -2934,8 +2934,8 @@ namespace Terminal.Gui { { ResetColumnTrack (); - if (!AllowsTab) { - return false; + if (!AllowsTab || isReadOnly) { + return ProcessMovePreviousView (); } if (currentColumn > 0) { var currentLine = GetCurrentLine (); @@ -2958,8 +2958,8 @@ namespace Terminal.Gui { { ResetColumnTrack (); - if (!AllowsTab) { - return false; + if (!AllowsTab || isReadOnly) { + return ProcessMoveNextView (); } InsertText (new KeyEvent ((Key)'\t', null)); DoNeededAction (); @@ -2977,11 +2977,9 @@ namespace Terminal.Gui { { ResetColumnTrack (); - if (!AllowsReturn) { + if (!AllowsReturn || isReadOnly) { return false; } - if (isReadOnly) - return true; var currentLine = GetCurrentLine ();