From 710e0888e0fcc8f9a0ab497446d3041d3272a0b9 Mon Sep 17 00:00:00 2001 From: Jay Cho Date: Wed, 10 Oct 2018 16:16:32 +0900 Subject: [PATCH] [ElmSharp] Fix Focus Clearing issue (#510) --- src/ElmSharp/ElmSharp/Widget.cs | 9 ++++++++- src/ElmSharp/Interop/Interop.Elementary.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/ElmSharp/Interop/Interop.Elementary.cs diff --git a/src/ElmSharp/ElmSharp/Widget.cs b/src/ElmSharp/ElmSharp/Widget.cs index 4a6fcbb..0831836 100644 --- a/src/ElmSharp/ElmSharp/Widget.cs +++ b/src/ElmSharp/ElmSharp/Widget.cs @@ -293,7 +293,14 @@ namespace ElmSharp /// preview public void SetFocus(bool isFocus) { - Interop.Elementary.elm_object_focus_set(RealHandle, isFocus); + if (isFocus) + { + Interop.Elementary.elm_object_focus_set(RealHandle, isFocus); + } + else + { + Interop.Elementary.elm_object_focused_clear(RealHandle); + } } /// diff --git a/src/ElmSharp/Interop/Interop.Elementary.cs b/src/ElmSharp/Interop/Interop.Elementary.cs old mode 100755 new mode 100644 index 5e7acc4..8a8cb0c --- a/src/ElmSharp/Interop/Interop.Elementary.cs +++ b/src/ElmSharp/Interop/Interop.Elementary.cs @@ -91,6 +91,33 @@ internal static partial class Interop return Marshal.PtrToStringAnsi(_elm_config_profile_get()); } + internal static void elm_object_focused_clear(IntPtr handle) + { + if (elm_widget_is(handle)) + { + efl_ui_widget_focused_object_clear(handle); + } + else + { + Evas.evas_object_focus_set(handle, false); + } + + IntPtr win = elm_widget_top_get(handle); + if (win != IntPtr.Zero && Eo.efl_class_name_get(Eo.efl_class_get(win)) == "Efl.Ui.Win") + { + Evas.evas_object_focus_set(win, true); + } + } + + [DllImport(Libraries.Elementary)] + internal static extern IntPtr elm_widget_top_get(IntPtr handle); + + [DllImport(Libraries.Elementary)] + internal static extern bool elm_widget_is(IntPtr handle); + + [DllImport(Libraries.Elementary)] + internal static extern void efl_ui_widget_focused_object_clear(IntPtr handle); + [DllImport(Libraries.Elementary)] internal static extern void elm_config_preferred_engine_set(string name); -- 2.7.4