From 847be89ed256359a39d3af5565e70bffc331fe03 Mon Sep 17 00:00:00 2001 From: BDisp Date: Fri, 22 May 2020 01:17:05 +0100 Subject: [PATCH] Make a disable color for ReadOnly in the TextField. Also make the methods Copy, Cut and Paste as virtual. --- Terminal.Gui/Views/TextField.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index bd8e939aa..71a53ccd7 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -192,6 +192,7 @@ namespace Terminal.Gui { int col = 0; int width = Frame.Width; var tcount = text.Count; + var roc = new Attribute (Color.DarkGray, Color.Gray); for (int idx = 0; idx < tcount; idx++){ var rune = text [idx]; if (idx < p) @@ -200,7 +201,7 @@ namespace Terminal.Gui { if (col == point && HasFocus && !Used && SelectedLength == 0 && !ReadOnly) Driver.SetAttribute (Colors.Menu.HotFocus); else if (ReadOnly) - Driver.SetAttribute (idx >= start && length > 0 && idx < start + length ? color.Focus : color.Disabled); + Driver.SetAttribute (idx >= start && length > 0 && idx < start + length ? color.Focus : roc); else Driver.SetAttribute (idx >= start && length > 0 && idx < start + length ? color.Focus : ColorScheme.Focus); if (col + cols <= width) @@ -713,7 +714,7 @@ namespace Terminal.Gui { /// /// Copy the selected text to the clipboard. /// - public void Copy () + public virtual void Copy () { if (Secret) return; @@ -726,7 +727,7 @@ namespace Terminal.Gui { /// /// Cut the selected text to the clipboard. /// - public void Cut () + public virtual void Cut () { if (SelectedLength != 0) { Clipboard.Contents = SelectedText; @@ -749,7 +750,7 @@ namespace Terminal.Gui { /// /// Paste the selected text from the clipboard. /// - public void Paste () + public virtual void Paste () { if (ReadOnly) return;