Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CharacterSpacing property in WinUI Editor #1153

Merged
merged 2 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Controls/samples/Controls.Sample/Pages/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void SetupMauiLayout()
verticalStack.Add(visibleClearButtonEntry);
verticalStack.Add(hiddenClearButtonEntry);

verticalStack.Add(new Editor { Text = "Editor using CharacterSpacing", CharacterSpacing = 10 });
verticalStack.Add(new Editor { Placeholder = "This is an editor placeholder." });
verticalStack.Add(new Editor { Placeholder = "Green Text Color.", TextColor = Colors.Green });
var paddingButton = new Button
Expand Down
6 changes: 4 additions & 2 deletions src/Core/src/Handlers/Editor/EditorHandler.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public static void MapPlaceholder(EditorHandler handler, IEditor editor)
[MissingMapper]
public static void MapPlaceholderColor(IViewHandler handler, IEditor editor) { }

[MissingMapper]
public static void MapCharacterSpacing(IViewHandler handler, IEditor editor) { }
public static void MapCharacterSpacing(EditorHandler handler, IEditor editor)
{
handler.NativeView?.UpdateCharacterSpacing(editor);
}

public static void MapMaxLength(EditorHandler handler, IEditor editor)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Core/src/Platform/Windows/TextBoxExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public static void UpdateTextColor(this MauiTextBox textBox, ITextStyle textStyl
textBox.ForegroundFocusBrush = brush;
}

public static void UpdateCharacterSpacing(this MauiTextBox textBox, ITextStyle textStyle)
{
textBox.CharacterSpacing = textStyle.CharacterSpacing.ToEm();
}

public static void UpdateCharacterSpacing(this MauiTextBox textBox, IEntry entry)
{
textBox.CharacterSpacing = entry.CharacterSpacing.ToEm();
Expand Down