зеркало из https://github.com/DeGsoft/maui-linux.git
Fix mac os Editor transparent color handling (#3218)
This commit is contained in:
Родитель
15fe14d88f
Коммит
c9ef84345d
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче