From 118c5b572081c2deca4dee75d1812cd1f9529744 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 11 Oct 2019 13:11:46 -0400 Subject: [Debugger] Fixed the Placeholder text color when the row is selected/edited Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1000541/ --- .../ObjectValue/Mac/MacDebuggerObjectNameView.cs | 20 +++++++++++++++++++- .../ObjectValue/Mac/MacDebuggerObjectValueView.cs | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs index 65dfc8bd56..e381997c28 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs @@ -53,6 +53,24 @@ namespace MonoDevelop.Debugger this.nameView = nameView; } + public override bool AcceptsFirstResponder () + { + if (!base.AcceptsFirstResponder ()) + return false; + + // Note: The MacDebuggerObjectNameView sets the PlaceholderAttributedString property + // so that it can control the font color and the baseline offset. Unfortunately, this + // breaks once the NSTextField is in "edit" mode because the placeholder text ends up + // being rendered as black instead of gray. By reverting to using the basic + // PlaceholderString property once we enter "edit" mode, it fixes the text color. + var placeholder = PlaceholderAttributedString; + + if (placeholder != null) + PlaceholderString = placeholder.Value; + + return true; + } + public override void DidBeginEditing (NSNotification notification) { base.DidBeginEditing (notification); @@ -111,7 +129,7 @@ namespace MonoDevelop.Debugger TextField = new EditableTextField (this) { AutoresizingMask = NSViewResizingMask.WidthSizable, TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = NSColor.Clear, + DrawsBackground = false, Bordered = false, Editable = false }; diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs index 07e0ed062a..0928aa5d53 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs @@ -53,6 +53,24 @@ namespace MonoDevelop.Debugger this.valueView = valueView; } + public override bool AcceptsFirstResponder () + { + if (!base.AcceptsFirstResponder ()) + return false; + + // Note: The MacDebuggerObjectValueView sets the PlaceholderAttributedString property + // so that it can control the font color and the baseline offset. Unfortunately, this + // breaks once the NSTextField is in "edit" mode because the placeholder text ends up + // being rendered as black instead of gray. By reverting to using the basic + // PlaceholderString property once we enter "edit" mode, it fixes the text color. + var placeholder = PlaceholderAttributedString; + + if (placeholder != null) + PlaceholderString = placeholder.Value; + + return true; + } + public override void DidBeginEditing (NSNotification notification) { base.DidBeginEditing (notification); @@ -135,7 +153,7 @@ namespace MonoDevelop.Debugger TextField = new EditableTextField (this) { AutoresizingMask = NSViewResizingMask.WidthSizable, TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = NSColor.Clear, + DrawsBackground = false, Bordered = false, Editable = false }; -- cgit v1.2.3