Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[GTK] Fix Entry focus behavior #14165

Merged
merged 2 commits into from
Apr 28, 2021
Merged
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
13 changes: 10 additions & 3 deletions Xamarin.Forms.Platform.GTK/Renderers/EntryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
SetNativeControl(wrapper);

wrapper.Entry.Changed += OnChanged;
wrapper.Entry.Focused += OnFocused;
wrapper.Entry.FocusInEvent += OnFocusedIn;
wrapper.Entry.FocusOutEvent += OnFocusedOut;
wrapper.Entry.EditingDone += OnEditingDone;
wrapper.Entry.KeyReleaseEvent += OnKeyReleased;
}
Expand Down Expand Up @@ -76,7 +77,8 @@ protected override void Dispose(bool disposing)
if (Control != null)
{
Control.Entry.Changed -= OnChanged;
Control.Entry.Focused -= OnFocused;
Control.Entry.FocusInEvent -= OnFocusedIn;
Control.Entry.FocusOutEvent -= OnFocusedOut;
Control.Entry.EditingDone -= OnEditingDone;
Control.Entry.KeyReleaseEvent -= OnKeyReleased;
}
Expand Down Expand Up @@ -139,11 +141,16 @@ private void OnChanged(object sender, System.EventArgs e)
ElementController.SetValueFromRenderer(Entry.TextProperty, Control.Entry.Text);
}

private void OnFocused(object o, FocusedArgs args)
private void OnFocusedIn(object o, FocusInEventArgs args)
{
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}

private void OnFocusedOut(object o, FocusOutEventArgs args)
{
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}

private void OnEditingDone(object sender, System.EventArgs e)
{
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Expand Down