Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 181e809

Browse files
committed
[Debugger] Fixed the Placeholder text color when the row is selected/edited
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1000541/
1 parent d6129fc commit 181e809

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ public EditableTextField (MacDebuggerObjectNameView nameView)
5353
this.nameView = nameView;
5454
}
5555

56+
public override bool AcceptsFirstResponder ()
57+
{
58+
if (!base.AcceptsFirstResponder ())
59+
return false;
60+
61+
// Note: The MacDebuggerObjectNameView sets the PlaceholderAttributedString property
62+
// so that it can control the font color and the baseline offset. Unfortunately, this
63+
// breaks once the NSTextField is in "edit" mode because the placeholder text ends up
64+
// being rendered as black instead of gray. By reverting to using the basic
65+
// PlaceholderString property once we enter "edit" mode, it fixes the text color.
66+
var placeholder = PlaceholderAttributedString;
67+
68+
if (placeholder != null)
69+
PlaceholderString = placeholder.Value;
70+
71+
return true;
72+
}
73+
5674
public override void DidBeginEditing (NSNotification notification)
5775
{
5876
base.DidBeginEditing (notification);
@@ -111,7 +129,7 @@ public MacDebuggerObjectNameView (MacObjectValueTreeView treeView) : base (treeV
111129
TextField = new EditableTextField (this) {
112130
AutoresizingMask = NSViewResizingMask.WidthSizable,
113131
TranslatesAutoresizingMaskIntoConstraints = false,
114-
BackgroundColor = NSColor.Clear,
132+
DrawsBackground = false,
115133
Bordered = false,
116134
Editable = false
117135
};

main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectValueView.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ public EditableTextField (MacDebuggerObjectValueView valueView)
5353
this.valueView = valueView;
5454
}
5555

56+
public override bool AcceptsFirstResponder ()
57+
{
58+
if (!base.AcceptsFirstResponder ())
59+
return false;
60+
61+
// Note: The MacDebuggerObjectValueView sets the PlaceholderAttributedString property
62+
// so that it can control the font color and the baseline offset. Unfortunately, this
63+
// breaks once the NSTextField is in "edit" mode because the placeholder text ends up
64+
// being rendered as black instead of gray. By reverting to using the basic
65+
// PlaceholderString property once we enter "edit" mode, it fixes the text color.
66+
var placeholder = PlaceholderAttributedString;
67+
68+
if (placeholder != null)
69+
PlaceholderString = placeholder.Value;
70+
71+
return true;
72+
}
73+
5674
public override void DidBeginEditing (NSNotification notification)
5775
{
5876
base.DidBeginEditing (notification);
@@ -135,7 +153,7 @@ public MacDebuggerObjectValueView (MacObjectValueTreeView treeView) : base (tree
135153
TextField = new EditableTextField (this) {
136154
AutoresizingMask = NSViewResizingMask.WidthSizable,
137155
TranslatesAutoresizingMaskIntoConstraints = false,
138-
BackgroundColor = NSColor.Clear,
156+
DrawsBackground = false,
139157
Bordered = false,
140158
Editable = false
141159
};

0 commit comments

Comments
 (0)