forked from enlightenment/efl
elementary: add a mode to entry to clear selection when loosing focus.
Patch by Thiep Ha <thiep.ha@samsung.com>. SVN revision: 79821
This commit is contained in:
parent
1007f38bdc
commit
8327932076
|
@ -722,3 +722,7 @@
|
|||
|
||||
* Fix the mapbuf to update it's contents correctly, even if they go
|
||||
outside of the buffer
|
||||
|
||||
2012-11-29 Thiep Ha
|
||||
|
||||
* Entry: add a mode to clear selection when entry loose focus.
|
||||
|
|
|
@ -17,6 +17,7 @@ Additions:
|
|||
* Add elm_toolbar_item_show/bring_in.
|
||||
* Add elm_genlist_nth_item_get
|
||||
* Add elm_gengrid_nth_item_get
|
||||
* Add elm_config_selection_unfocused_clear_get and elm_config_selection_unfocused_clear_set
|
||||
|
||||
Improvements:
|
||||
|
||||
|
|
|
@ -598,6 +598,20 @@ ac_change(void *data __UNUSED__,
|
|||
elm_config_all_flush();
|
||||
}
|
||||
|
||||
static void
|
||||
sel_change(void *data __UNUSED__,
|
||||
Evas_Object *obj,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
Eina_Bool val = elm_check_state_get(obj);
|
||||
Eina_Bool sel = elm_config_selection_unfocused_clear_get();
|
||||
|
||||
if (val == sel) return;
|
||||
elm_config_selection_unfocused_clear_set(val);
|
||||
elm_config_all_flush();
|
||||
elm_config_save();
|
||||
}
|
||||
|
||||
static void
|
||||
_status_basic(Evas_Object *win,
|
||||
Evas_Object *bx0)
|
||||
|
@ -755,6 +769,14 @@ _cf_access(void *data,
|
|||
_flip_to(data, "access");
|
||||
}
|
||||
|
||||
static void
|
||||
_cf_selection(void *data,
|
||||
Evas_Object *obj __UNUSED__,
|
||||
void *event_info __UNUSED__)
|
||||
{
|
||||
_flip_to(data, "selection");
|
||||
}
|
||||
|
||||
const char *
|
||||
_elm_theme_current_get(const char *theme_search_order)
|
||||
{
|
||||
|
@ -1267,6 +1289,33 @@ _status_config_access(Evas_Object *win,
|
|||
elm_naviframe_item_simple_push(naviframe, bx);
|
||||
}
|
||||
|
||||
static void
|
||||
_status_config_selection(Evas_Object *win,
|
||||
Evas_Object *naviframe)
|
||||
{
|
||||
Evas_Object *bx, *ck;
|
||||
|
||||
bx = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
|
||||
|
||||
ck = elm_check_add(win);
|
||||
elm_object_tooltip_text_set(ck, "Set selection mode");
|
||||
elm_object_text_set(ck, "Enable clear selection when unfocus");
|
||||
evas_object_data_set(win, "selection_check", ck);
|
||||
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
|
||||
elm_check_state_set(ck, elm_config_selection_unfocused_clear_get());
|
||||
elm_box_pack_end(bx, ck);
|
||||
evas_object_show(ck);
|
||||
|
||||
evas_object_smart_callback_add(ck, "changed", sel_change, NULL);
|
||||
|
||||
evas_object_data_set(win, "selection", bx);
|
||||
|
||||
elm_naviframe_item_simple_push(naviframe, bx);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_sample_theme_new(Evas_Object *win)
|
||||
{
|
||||
|
@ -3046,6 +3095,7 @@ _status_config_full(Evas_Object *win,
|
|||
_cf_rendering, win);
|
||||
elm_toolbar_item_append(tb, "appointment-new", "Caches", _cf_caches, win);
|
||||
elm_toolbar_item_append(tb, "stock_spellcheck", "Access", _cf_access, win);
|
||||
elm_toolbar_item_append(tb, "clear-selection-check", "Selection", _cf_selection, win);
|
||||
|
||||
elm_box_pack_end(bx0, tb);
|
||||
evas_object_show(tb);
|
||||
|
@ -3062,6 +3112,7 @@ _status_config_full(Evas_Object *win,
|
|||
_status_config_scrolling(win, naviframe);
|
||||
_status_config_caches(win, naviframe);
|
||||
_status_config_access(win, naviframe);
|
||||
_status_config_selection(win, naviframe);
|
||||
_status_config_sizing(win, naviframe); // Note: call this at the end.
|
||||
|
||||
// FIXME uncomment after flip style fix, please
|
||||
|
|
|
@ -405,6 +405,7 @@ _desc_init(void)
|
|||
ELM_CONFIG_VAL(D, T, glayer_long_tap_start_timeout, T_DOUBLE);
|
||||
ELM_CONFIG_VAL(D, T, glayer_double_tap_timeout, T_DOUBLE);
|
||||
ELM_CONFIG_VAL(D, T, access_mode, T_UCHAR);
|
||||
ELM_CONFIG_VAL(D, T, selection_clear_enable, T_UCHAR);
|
||||
ELM_CONFIG_VAL(D, T, glayer_continues_enable, T_UCHAR);
|
||||
ELM_CONFIG_VAL(D, T, week_start, T_INT);
|
||||
ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
|
||||
|
@ -576,6 +577,18 @@ void _elm_config_access_set(Eina_Bool is_access)
|
|||
_elm_win_access(is_access);
|
||||
}
|
||||
|
||||
Eina_Bool _elm_config_selection_unfocused_clear_get(void)
|
||||
{
|
||||
return _elm_config->selection_clear_enable;
|
||||
}
|
||||
|
||||
void _elm_config_selection_unfocused_clear_set(Eina_Bool enabled)
|
||||
{
|
||||
enabled = !!enabled;
|
||||
if (_elm_config->selection_clear_enable == enabled) return;
|
||||
_elm_config->selection_clear_enable = enabled;
|
||||
}
|
||||
|
||||
void
|
||||
_elm_config_font_overlay_set(const char *text_class,
|
||||
const char *font,
|
||||
|
@ -1092,6 +1105,7 @@ _config_load(void)
|
|||
_elm_config->glayer_double_tap_timeout = 0.25; /* 0.25 seconds between 2 mouse downs of a tap. */
|
||||
_elm_config->glayer_continues_enable = EINA_TRUE; /* Continue gestures default */
|
||||
_elm_config->access_mode = ELM_ACCESS_MODE_OFF;
|
||||
_elm_config->selection_clear_enable = EINA_FALSE;
|
||||
_elm_config->week_start = 1; /* monday */
|
||||
_elm_config->weekend_start = 6; /* saturday */
|
||||
_elm_config->weekend_len = 2;
|
||||
|
@ -1594,6 +1608,9 @@ _env_get(void)
|
|||
s = getenv("ELM_ACCESS_MODE");
|
||||
if (s) _elm_config->access_mode = ELM_ACCESS_MODE_ON;
|
||||
|
||||
s = getenv("ELM_SELECTION_CLEAR_ENABLE");
|
||||
if (s) _elm_config->selection_clear_enable = !!atoi(s);
|
||||
|
||||
s = getenv("ELM_AUTO_THROTTLE");
|
||||
if (s) _elm_config->auto_throttle = EINA_TRUE;
|
||||
s = getenv("ELM_AUTO_THROTTLE_AMOUNT");
|
||||
|
@ -1799,6 +1816,18 @@ elm_config_access_set(Eina_Bool is_access)
|
|||
_elm_config_access_set(is_access);
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
elm_config_selection_unfocused_clear_get(void)
|
||||
{
|
||||
return _elm_config_selection_unfocused_clear_get();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_config_selection_unfocused_clear_set(Eina_Bool enabled)
|
||||
{
|
||||
_elm_config_selection_unfocused_clear_set(enabled);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_config_font_overlay_set(const char *text_class,
|
||||
const char *font,
|
||||
|
|
|
@ -755,6 +755,33 @@ EAPI Eina_Bool elm_config_access_get(void);
|
|||
*/
|
||||
EAPI void elm_config_access_set(Eina_Bool is_access);
|
||||
|
||||
/**
|
||||
* Get whether selection should be cleared when entry widget is unfocused.
|
||||
*
|
||||
* @return if the selection would be cleared on unfocus.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @ingroup Selection
|
||||
*
|
||||
* @see elm_config_selection_unfocused_clear_set()
|
||||
*/
|
||||
EAPI Eina_Bool elm_config_selection_unfocused_clear_get(void);
|
||||
|
||||
/**
|
||||
* Set whether selection should be cleared when entry widget is unfocused.
|
||||
*
|
||||
* @param enabled If EINA_TRUE clear selection when unfocus,
|
||||
* otherwise does not clear selection when unfocus.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @ingroup Selection
|
||||
*
|
||||
* @see elm_config_selection_unfocused_clear_get()
|
||||
*/
|
||||
EAPI void elm_config_selection_unfocused_clear_set(Eina_Bool enabled);
|
||||
|
||||
/**
|
||||
* Unset a font overlay for a given Elementary text class.
|
||||
*
|
||||
|
|
|
@ -860,6 +860,18 @@ _elm_entry_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
|||
if (top && top_is_win && sd->input_panel_enable)
|
||||
elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
|
||||
evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
|
||||
|
||||
if (_elm_config->selection_clear_enable)
|
||||
{
|
||||
if ((sd->have_selection) && (!sd->hoversel))
|
||||
{
|
||||
sd->sel_mode = EINA_FALSE;
|
||||
elm_widget_scroll_hold_pop(obj);
|
||||
edje_object_part_text_select_allow_set(sd->entry_edje, "elm.text", EINA_FALSE);
|
||||
edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
|
||||
edje_object_part_text_select_none(sd->entry_edje, "elm.text");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) *ret = EINA_TRUE;
|
||||
|
|
|
@ -233,6 +233,7 @@ struct _Elm_Config
|
|||
const char *indicator_service_90;
|
||||
const char *indicator_service_180;
|
||||
const char *indicator_service_270;
|
||||
unsigned char selection_clear_enable;
|
||||
|
||||
/* Not part of the EET file */
|
||||
Eina_Bool is_mirrored : 1;
|
||||
|
|
Loading…
Reference in New Issue