{NULL, NULL}
};
+static const char SIG_CLICKED[] = "clicked";
+
static void
_item_content_del_cb(void *data,
Evas *e __UNUSED__,
multiple times on some heavy environment. This callback del will
prevent those scenario and guarantee only one clicked for it's own
page. */
- evas_object_smart_callback_del(obj, "clicked", _on_item_back_btn_clicked);
+ evas_object_smart_callback_del(obj, SIG_CLICKED, _on_item_back_btn_clicked);
elm_naviframe_item_pop(data);
}
if (!btn) return NULL;
evas_object_smart_callback_add
- (btn, "clicked", _on_item_back_btn_clicked, obj);
+ (btn, SIG_CLICKED, _on_item_back_btn_clicked, obj);
snprintf
(buf, sizeof(buf), "naviframe/back_btn/%s", elm_widget_style_get(obj));
elm_object_style_set(btn, buf);
evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_on_obj_size_hints_changed, obj);
- elm_widget_can_focus_set(obj, EINA_FALSE);
+ elm_widget_can_focus_set(obj, EINA_TRUE);
if (!elm_widget_sub_object_add(eo_parent_get(obj), obj))
ERR("could not add %p as sub object of %p", obj, eo_parent_get(obj));
}
static void
+_elm_naviframe_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
+{
+ Evas_Object *source = va_arg(*list, Evas_Object *);
+ Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
+ Evas_Event_Key_Down *ev = va_arg(*list, Evas_Event_Key_Down *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+ Elm_Naviframe_Item *it;
+ (void) source;
+
+ if (ret) *ret = EINA_FALSE;
+ if (elm_widget_disabled_get(obj)) return;
+ if (type != EVAS_CALLBACK_KEY_DOWN) return;
+ if (strcmp(ev->keyname, "BackSpace")) return;
+
+ eo_do(obj, elm_obj_naviframe_top_item_get((Elm_Object_Item **)&it));
+ if (!it) return;
+
+ if (it->title_prev_btn)
+ evas_object_smart_callback_call(it->title_prev_btn, SIG_CLICKED, NULL);
+
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+}
+
+static void
_elm_naviframe_smart_access(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
{
Elm_Naviframe_Smart_Data *sd = _pd;
it = (Elm_Naviframe_Item *)elm_naviframe_top_item_get(obj);
if (!it) return;
+ if (it->pop_cb) it->pop_cb(it->pop_data, (Elm_Object_Item *)it);
+
if (sd->preserve)
content = it->content;
}
EAPI void
+elm_naviframe_item_pop_cb_set(Elm_Object_Item *it, Elm_Naviframe_Item_Pop_Cb func, void *data)
+{
+ Elm_Naviframe_Item *nit = (Elm_Naviframe_Item *)it;
+
+ ELM_NAVIFRAME_ITEM_CHECK_OR_RETURN(it);
+
+ nit->pop_cb = func;
+ nit->pop_data = data;
+}
+
+EAPI void
elm_naviframe_prev_btn_auto_pushed_set(Evas_Object *obj,
Eina_Bool auto_pushed)
{
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT), _elm_naviframe_smart_focus_next),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_naviframe_smart_theme),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ACCESS), _elm_naviframe_smart_access),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_EVENT), _elm_naviframe_smart_event),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET), _elm_naviframe_smart_content_set),
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET), _elm_naviframe_smart_content_get),
#define elm_obj_naviframe_event_enabled_get(ret) ELM_OBJ_NAVIFRAME_ID(ELM_OBJ_NAVIFRAME_SUB_ID_EVENT_ENABLED_GET), EO_TYPECHECK(Eina_Bool *, ret)
/**
+ * @typedef Elm_Naviframe_Item_Pop_Cb
+ *
+ * Pop callback called when @c it is going to be popped. @c data is user
+ * specific data.
+ *
+ * @see elm_naviframe_item_pop_cb_set()
+ *
+ * @since 1.8
+ */
+typedef void (*Elm_Naviframe_Item_Pop_Cb)(void *data, Elm_Object_Item *it);
+
+/**
* @addtogroup Naviframe
* @{
*/
* stack will become visible.
*
* @see also elm_naviframe_content_preserve_on_pop_get()
+ * @see also elm_naviframe_item_pop_cb_set()
*
* @ingroup Naviframe
*/
EAPI Eina_Bool elm_naviframe_item_title_visible_get(const Elm_Object_Item *it);
/**
+ * @brief Set a function to be called when @c it of the naviframe is going to be
+ * popped.
+ *
+ * @param it The item to set the callback on
+ * @param func the callback function.
+ *
+ * @warning Don't set "clicked" callback to the prev button additionally if the
+ * function does a exact same logic with this @c func. When hardware back key is
+ * pressed then both callbacks will be called.
+ *
+ * @since 1.8
+ * @ingroup Naviframe
+ */
+EAPI void elm_naviframe_item_pop_cb_set(Elm_Object_Item *it, Elm_Naviframe_Item_Pop_Cb func, void *data);
+
+/**
* @brief Set creating prev button automatically or not
*
* @param obj The naviframe object