New focus move policy, ELM_FOCUS_MOVE_POLICY_KEY_ONLY, is added.
If you set this policy as base focus move policy, objects cannot steal
focus by using mouse click or mouse in. Only keyboard input (such as Left,
Right, Up, Down, ...) can make focus be moved.
Additaionally, an object can have its own focus move policy by using
elm_object_focus_move_policy_set API.
@feature
Change-Id: Iaa64ce2e92b2a376d000907e2986873fa542e655
origin: upstream
test_floating.c \
test_focus.c \
test_focus_custom_chain.c \
+test_focus_policy.c \
test_focus_style.c \
test_gengrid.c \
test_genlist.c \
void test_focus_part(void *data, Evas_Object *obj, void *event_info);
void test_focus3(void *data, Evas_Object *obj, void *event_info);
void test_focus_object_style(void *data, Evas_Object *obj, void *event_info);
+void test_focus_object_policy(void *data, Evas_Object *obj, void *event_info);
void test_flipselector(void *data, Evas_Object *obj, void *event_info);
void test_diskselector(void *data, Evas_Object *obj, void *event_info);
void test_colorselector(void *data, Evas_Object *obj, void *event_info);
ADD_TEST(NULL, "Focus", "Focus On Part", test_focus_part);
ADD_TEST(NULL, "Focus", "Focus 3", test_focus3);
ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style);
+ ADD_TEST(NULL, "Focus", "Focus Object Policy", test_focus_object_policy);
//------------------------------//
ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe);
typedef enum
{
ELM_FOCUS_MOVE_POLICY_CLICK, /**< move focus by mouse click or touch. Elementary focus is set on mouse click and this is checked at mouse up time. (default) */
- ELM_FOCUS_MOVE_POLICY_IN /**< move focus by mouse in. Elementary focus is set on mouse move when the mouse pointer is moved into an object. */
+ ELM_FOCUS_MOVE_POLICY_IN, /**< move focus by mouse in. Elementary focus is set on mouse move when the mouse pointer is moved into an object. */
+ ELM_FOCUS_MOVE_POLICY_KEY_ONLY /**< move focus by key. Elementary focus is set on key input like Left, Right, Up, Down, Tab, or Shift+Tab.*/
} Elm_Focus_Move_Policy;
/**
* @since 1.10
*/
EAPI Elm_Object_Item *elm_object_focused_item_get(const Evas_Object *obj);
+
+/**
+ * Set the focus movement policy to a given Elementary object.
+ *
+ * @param obj The Elementary object to operate on
+ * @param policy A policy to apply for the focus movement
+ *
+ * @see elm_object_focus_move_policy_get
+ *
+ * @since 1.15
+ *
+ * @ingroup Focus
+ */
+EAPI void elm_object_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy);
+
+/**
+ * Get the focus movement policy from a given Elementary objet.
+ *
+ * @param obj The Elementary widget to get the information from
+ * @return The focus movement policy
+ *
+ * Get how the focus is moved to the give Elemenray object. It can be
+ * #ELM_FOCUS_MOVE_POLICY_CLICK, #ELM_FOCUS_MOVE_POLICY_IN,
+ * or #ELM_FOCUS_MOVE_POLICY_KEY_ONLY.
+ * The first means elementary focus is moved on elementary object click.
+ * The second means elementary focus is moved on elementary object mouse in.
+ * The last means elementary focus is moved only by key input like Left,
+ * Right, Up, Down, Tab, or Shift+Tab.
+ *
+ * @see elm_object_focus_move_policy_set
+ *
+ * @since 1.15
+ *
+ * @ingroup Focus
+ */
+EAPI Elm_Focus_Move_Policy elm_object_focus_move_policy_get(Evas_Object *obj);
}
EAPI void
+elm_object_focus_move_policy_set(Evas_Object *obj,
+ Elm_Focus_Move_Policy policy)
+{
+ EINA_SAFETY_ON_NULL_RETURN(obj);
+ elm_widget_focus_move_policy_set(obj, policy);
+}
+
+EAPI Elm_Focus_Move_Policy
+elm_object_focus_move_policy_get(Evas_Object *obj)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
+ return elm_widget_focus_move_policy_get(obj);
+}
+
+EAPI void
elm_object_scroll_hold_push(Evas_Object *obj)
{
EINA_SAFETY_ON_NULL_RETURN(obj);
{
ELM_WIDGET_DATA_GET(data, sd);
if (sd->still_in &&
- (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
+ (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
elm_widget_focus_mouse_up_handle(obj);
sd->still_in = EINA_FALSE;
}
static void
-_obj_mouse_in(void *data EINA_UNUSED,
+_obj_mouse_in(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj,
void *event_info EINA_UNUSED)
{
- if (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
+ ELM_WIDGET_DATA_GET(data, sd);
+ if (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
elm_widget_focus_mouse_up_handle(obj);
}
* settings */
elm_widget_can_focus_set(obj, EINA_TRUE);
priv->is_mirrored = elm_config_mirrored_get();
+ priv->focus_move_policy = _elm_config->focus_move_policy;
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
_obj_mouse_down, obj);
}
}
+/**
+ * @internal
+ *
+ * Returns the widget's focus move policy.
+ *
+ * @param obj The widget.
+ * @return focus move policy of the object.
+ *
+ **/
+EOLIAN static Elm_Focus_Move_Policy
+_elm_widget_focus_move_policy_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
+{
+ return sd->focus_move_policy;
+}
+
+/**
+ * @internal
+ *
+ * Sets the widget's focus move policy.
+ *
+ * @param obj The widget.
+ * @param policy Elm_Focus_Momve_Policy to set object's focus move policy.
+ */
+
+EOLIAN static void
+_elm_widget_focus_move_policy_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Move_Policy policy)
+{
+ if (sd->focus_move_policy == policy) return;
+ sd->focus_move_policy = policy;
+}
static void
_track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
const(char)* label;
}
}
+ focus_move_policy {
+ set {
+ /*@ No description supplied by the EAPI. */
+ }
+ get {
+ /*@ No description supplied by the EAPI. */
+ }
+ values {
+ Elm_Focus_Move_Policy policy;
+ }
+ }
}
methods {
newest_focus_order_get @const {
Evas_Object *obj);
int orient_mode; /* -1 is disabled */
+ Elm_Focus_Move_Policy focus_move_policy;
Eina_Bool drag_x_locked : 1;
Eina_Bool drag_y_locked : 1;
EAPI Eina_Bool elm_widget_orientation_mode_disabled_get(const Evas_Object *obj);
EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it);
+EAPI void elm_widget_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy);
+EAPI Elm_Focus_Move_Policy elm_widget_focus_move_policy_get(const Evas_Object *obj);
/**
* Function to operate on a given widget's scrollabe children when necessary.