Skip to content
Open
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
IsEnabled="{Binding IsEnabled}"
FlowDirection="{Binding FlowDirection}"
HeightRequest="{Binding HeightRequest}"
WidthRequest="{Binding WidthRequest}"
BackgroundColor="{Binding BackgroundColor}"
Opacity="{Binding Opacity}"
FontAttributes="{Binding FontAttributes}"
TextTransform="{Binding TextTransform}"
TextChanged="EntryControl_TextChanged"
Expand All @@ -52,7 +55,7 @@
<Button Text="Options"
FontSize="11"
Clicked="NavigateToOptionsPage_Clicked"
AutomationId="OptionsButton"/>
AutomationId="Options"/>

<Grid ColumnSpacing="10"
Margin="0,10,0,10">
Expand Down Expand Up @@ -86,6 +89,7 @@
<local:UITestEntry x:Name="CursorPositionEntry"
Text="{Binding CursorPosition}"
AutomationId="CursorPositionEntry"
TextChanged="CursorPositionButton_Clicked"
IsCursorVisible="False"
Comment on lines 89 to 93
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CursorPositionEntry is wired to TextChanged but the handler is named CursorPositionButton_Clicked (and takes EventArgs). Renaming the handler (and parameter type) to reflect it’s a TextChanged handler would make the intent clearer and reduce confusion when navigating the code.

Copilot uses AI. Check for mistakes.
Grid.Row="1"
Grid.Column="1"/>
Expand Down Expand Up @@ -115,4 +119,4 @@
AutomationId="UnfocusedLabel"
FontSize="11"/>
</VerticalStackLayout>
</ContentPage>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ public EntryControlMainPage(EntryViewModel viewModel)

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new EntryViewModel();
_viewModel.Text = "Test Entry";
_viewModel.Placeholder = "Enter text here";
_viewModel.CursorPosition = 0;
_viewModel.SelectionLength = 0;
_viewModel.Reset();
await Navigation.PushAsync(new EntryOptionsPage(_viewModel));
}

Expand All @@ -51,7 +47,6 @@ private void CursorPositionButton_Clicked(object sender, EventArgs e)
_viewModel.CursorPosition = cursorPosition;
}
}

private void SelectionLength_Clicked(object sender, EventArgs e)
{
if (int.TryParse(SelectionLengthEntry.Text, out int selectionLength))
Expand Down Expand Up @@ -130,4 +125,4 @@ private void EntryControl_Unfocused(object sender, FocusEventArgs e)
vm.UnfocusedText = eventInfo;
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ private void TextColorButton_Clicked(object sender, EventArgs e)
{
if (sender is Button button)
{
_viewModel.TextColor = button.BackgroundColor;
_viewModel.TextColor = button.AutomationId switch
{
"TextColorRed" => Colors.Red,
"TextColorBlue" => Colors.Blue,
_ => null
};
}
}

Expand All @@ -47,7 +52,12 @@ private void PlaceholderColorButton_Clicked(object sender, EventArgs e)
{
if (sender is Button button)
{
_viewModel.PlaceholderColor = button.BackgroundColor;
_viewModel.PlaceholderColor = button.AutomationId switch
{
"PlaceholderColorRed" => Colors.Red,
"PlaceholderColorBlue" => Colors.Blue,
_ => null
};
}
}

Expand Down Expand Up @@ -121,7 +131,7 @@ private void ReturnTypeButton_Clicked(object sender, EventArgs e)
}
}

private void MaxLengthButton_Clicked(object sender, EventArgs e)
private void MaxLengthEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if (int.TryParse(MaxLengthEntry.Text, out int maxLength))
{
Expand Down Expand Up @@ -256,19 +266,54 @@ private void TextTransform_CheckedChanged(object sender, CheckedChangedEventArgs
}
}

private void FontAttributes_CheckedChanged(object sender, CheckedChangedEventArgs e)
private void BackgroundColorButton_Clicked(object sender, EventArgs e)
{
if (sender is Button button)
{
_viewModel.BackgroundColor = button.AutomationId switch
{
"BackgroundColorYellow" => Colors.Yellow,
"BackgroundColorLightBlue" => Colors.LightBlue,
_ => null
};
}
}

private void WidthRequestEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if (sender == FontAttributesBold)
if (double.TryParse(e.NewTextValue, out double widthRequest))
{
_viewModel.FontAttributes = FontAttributes.Bold;
_viewModel.WidthRequest = widthRequest;
}
else if (sender == FontAttributesNone)
}
Comment on lines +282 to +288
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WidthRequestEntry_TextChanged currently accepts any parsed double (including negative values other than -1). Since WidthRequest semantics are “-1 = unset, otherwise non-negative”, consider coercing values < 0 to -1 (or ignoring them) so invalid widths can’t be applied via the options UI.

Copilot uses AI. Check for mistakes.

private void OpacityEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if (double.TryParse(e.NewTextValue, out double opacity))
{
_viewModel.FontAttributes = FontAttributes.None;
opacity = Math.Clamp(opacity, 0.0, 1.0);
_viewModel.Opacity = opacity;
}
else if (sender == FontAttributesItalic)
}

private void HeightRequestEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if (double.TryParse(e.NewTextValue, out double heightRequest))
{
_viewModel.FontAttributes = FontAttributes.Italic;
_viewModel.HeightRequest = heightRequest;
}
}
Comment on lines +299 to 305
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HeightRequestEntry_TextChanged sets HeightRequest directly from user input without validating range. Given HeightRequest uses “-1 = unset, otherwise non-negative”, consider coercing values < 0 to -1 (or ignoring them) to avoid applying invalid heights via the options UI.

Copilot uses AI. Check for mistakes.
}

private void FontAttributesCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
var attributes = FontAttributes.None;

if (FontAttributesBoldCheckBox.IsChecked)
attributes |= FontAttributes.Bold;

if (FontAttributesItalicCheckBox.IsChecked)
attributes |= FontAttributes.Italic;

_viewModel.FontAttributes = attributes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace Maui.Controls.Sample;
public class EntryViewModel : INotifyPropertyChanged
{
private string _text = "Test Entry";
private Color _textColor = Colors.Black;
private Color _textColor = null;
private string _placeholder = "Enter text here";
private Color _placeholderColor = Colors.Gray;
private Color _placeholderColor = null;
private double _fontSize = 14;
private double _heightrequest = -1;
private TextAlignment _horizontalTextAlignment = TextAlignment.Start;
Expand All @@ -25,8 +25,11 @@ public class EntryViewModel : INotifyPropertyChanged
private bool _isSpellCheckEnabled = false;
private Keyboard _keyboard = Keyboard.Default;
private string _fontFamily = null;
private bool isVisible = true;
private bool _isVisible = true;
private bool _isEnabled = true;
private Color _backgroundColor = null;
private double _opacity = 1.0;
private double _widthRequest = -1;
private ClearButtonVisibility _clearButtonVisibility = ClearButtonVisibility.WhileEditing;
private FlowDirection _flowDirection = FlowDirection.LeftToRight;
private bool _hasShadow = false;
Expand Down Expand Up @@ -157,8 +160,8 @@ public bool IsSpellCheckEnabled

public bool IsVisible
{
get => isVisible;
set { isVisible = value; OnPropertyChanged(); }
get => _isVisible;
set { _isVisible = value; OnPropertyChanged(); }
}

public bool IsEnabled
Expand All @@ -167,6 +170,24 @@ public bool IsEnabled
set { _isEnabled = value; OnPropertyChanged(); }
}

public Color BackgroundColor
{
get => _backgroundColor;
set { _backgroundColor = value; OnPropertyChanged(); }
}

public double Opacity
{
get => _opacity;
set { _opacity = value; OnPropertyChanged(); }
}

public double WidthRequest
{
get => _widthRequest;
set { _widthRequest = value; OnPropertyChanged(); }
}

public Keyboard Keyboard
{
get => _keyboard;
Expand Down Expand Up @@ -270,8 +291,45 @@ public FontAttributes FontAttributes
}
}

public void Reset()
{
TextColor = null;
PlaceholderColor = null;
FontSize = 14;
HeightRequest = -1;
WidthRequest = -1;
BackgroundColor = null;
Opacity = 1.0;
HorizontalTextAlignment = TextAlignment.Start;
VerticalTextAlignment = TextAlignment.Center;
IsPassword = false;
CharacterSpacing = 0;
ReturnType = ReturnType.Default;
MaxLength = -1;
IsReadOnly = false;
IsTextPredictionEnabled = false;
IsSpellCheckEnabled = false;
Keyboard = Keyboard.Default;
FontFamily = null;
IsVisible = true;
IsEnabled = true;
ClearButtonVisibility = ClearButtonVisibility.WhileEditing;
FlowDirection = FlowDirection.LeftToRight;
HasShadow = false;
TextTransform = TextTransform.Default;
FontAttributes = FontAttributes.None;
Text = "Test Entry";
Placeholder = "Enter text here";
TextChangedText = "TextChanged: Not triggered";
CompletedText = "Completed: Not triggered";
FocusedText = "Focused: Not triggered";
UnfocusedText = "Unfocused: Not triggered";
CursorPosition = 0;
SelectionLength = 0;
}

protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Loading
Loading