Closed FrankVDL2471 closed 5 months ago
I just checked this, seems to be an issue but I am not sure if I can actually add a fix to this soon, To be honest not even sure if I know how to fix this lol.
So after some RnD, I found that as soon as you add the Entry into a ContentView custom control these properties stop working on Focus, But I am not 100% sure why yet!
As of right now, i think this is not fixable but i am still doing some RnD for this hopefully when i find a solution i will update you!
@FrankVDL2471 Need your help, I just tried this with the latest version of Android and this is not working with a basic entry, can you confirm if this works for you there?
@FrankVDL2471
This should solve your issue, I have just tested it let me know if this works so i can close this issue
public class SjwingEntry : FreakyTextInputLayout, IDisposable
{
private readonly Entry internalEntry;
public SjwingEntry()
{
this.BorderType = Shared.Enums.BorderType.Full;
this.BorderCornerRadius = 5;
this.BorderStrokeThickness = 2;
this.BorderStroke = Brush.DarkGray;
this.ControlBackgroundColor = Colors.White;
this.TextColor = Colors.Black;
this.FontFamily = "Default";
this.FontSize = 16;
internalEntry = this.FindByName<Entry>("EntryField");
internalEntry.Focused += SjwingEntry_Focused;
}
protected void Dispose()
{
internalEntry.Focused -= SjwingEntry_Focused;
}
private async void SjwingEntry_Focused(object sender, FocusEventArgs e)
{
internalEntry.SelectionLength = 0;
await Dispatcher.DispatchAsync(() =>
{
internalEntry.CursorPosition = 0;
internalEntry.SelectionLength = this.Text.Length;
});
}
}
Just tested it, and it seems to be working fine.
Thanks for the update
Awesome, I will. be closing this in that case!!
Hello,
I want all the text to be selected, when the control gets focus (is tabbed on) I tried the code below, but it does not seem to work. Any suggestions on how to make this work ?