Fix mac os Editor transparent color handling (#3218)

This commit is contained in:
John VanSickle 2018-08-01 13:43:21 -04:00 коммит произвёл Rui Marinho
Родитель 15fe14d88f
Коммит c9ef84345d
3 изменённых файлов: 49 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,35 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 3216, "[macOS] Editor still displays white background when BackgroundColor set to Transparent", PlatformAffected.macOS)]
public class GitHub3216 : TestContentPage
{
protected override void Init()
{
var grid = new Grid
{
BackgroundColor = Color.BurlyWood
};
var defaultEditor = new Editor
{
Text = "I'm a default Editor!"
};
var transparentEditor = new Editor
{
Text = "I'm a transparent Editor!",
BackgroundColor = Color.Transparent
};
Grid.SetRow(transparentEditor, 1);
grid.Children.Add(defaultEditor);
grid.Children.Add(transparentEditor);
Content = grid;
}
}
}

Просмотреть файл

@ -766,6 +766,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue2728.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1667.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3012.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitHub3216.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitHub1776.cs" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -71,6 +71,17 @@ namespace Xamarin.Forms.Platform.MacOS
Control.BackgroundColor = color == Color.Default ? NSColor.Clear : color.ToNSColor();
if (color == Color.Transparent)
{
Control.DrawsBackground = false;
Control.Bezeled = false;
}
else
{
Control.DrawsBackground = true;
Control.Bezeled = true;
}
base.SetBackgroundColor(color);
}
@ -92,14 +103,14 @@ namespace Xamarin.Forms.Platform.MacOS
void HandleChanged(object sender, EventArgs e)
{
UpdateMaxLength();
ElementController.SetValueFromRenderer(Editor.TextProperty, Control.StringValue);
}
void OnEditingEnded(object sender, EventArgs eventArgs)
{
Element.SetValue(VisualElement.IsFocusedPropertyKey, false);
ElementController.SendCompleted();
ElementController.SendCompleted();
}
void OnEditingBegan(object sender, EventArgs eventArgs)