浏览代码

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.
BDisp 3 年之前
父节点
当前提交
2e2566f0f0
共有 2 个文件被更改,包括 6 次插入8 次删除
  1. 1 1
      Terminal.Gui/Views/Button.cs
  2. 5 7
      Terminal.Gui/Views/TextView.cs

+ 1 - 1
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 {

+ 5 - 7
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 ();