entry - Add "rejected" smart callback in "elm_entry_filter_accept_set"

Summary:
Add "rejected" smart callback.
Applications using the *filter_accept_set didn't know when the input was rejected.
This smart callback can provide a simple information to applications.

Reviewers: woohyun, tasn, seoz

Reviewed By: seoz

Differential Revision: https://phab.enlightenment.org/D413
This commit is contained in:
Youngbok Shin 2013-12-30 18:25:15 +09:00 committed by Daniel Juyung Seo
parent 21da50f601
commit 205c264449
3 changed files with 26 additions and 2 deletions

View File

@ -273,6 +273,19 @@ _item_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
printf("\ncurrent selected text = %s\n", elm_entry_context_menu_item_label_get(item));
}
static void
_entry_rejected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Entry_Filter_Accept_Set *accept_set = data;
if (!accept_set) return;
if (accept_set->accepted)
printf("REJECTED: This entry only accepts the following character set: [%s]\n", accept_set->accepted);
else
printf("REJECTED: This entry rejects the following character set: [%s]\n", accept_set->rejected);
}
void
test_entry_scrolled(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@ -375,6 +388,7 @@ test_entry_scrolled(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
digits_filter_data.accepted = "0123456789";
digits_filter_data.rejected = NULL;
elm_entry_markup_filter_append(en, elm_entry_filter_accept_set, &digits_filter_data);
evas_object_smart_callback_add(en, "rejected", _entry_rejected_cb, &digits_filter_data);
/* No digits entry */
en = elm_entry_add(win);
@ -390,6 +404,7 @@ test_entry_scrolled(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
digits_filter_data2.accepted = NULL;
digits_filter_data2.rejected = "0123456789";
elm_entry_markup_filter_append(en, elm_entry_filter_accept_set, &digits_filter_data2);
evas_object_smart_callback_add(en, "rejected", _entry_rejected_cb, &digits_filter_data2);
/* Size limited entry */
en = elm_entry_add(win);

View File

@ -52,7 +52,8 @@ EAPI Eo_Op ELM_OBJ_ENTRY_BASE_ID = EO_NOOP;
cmd(SIG_SELECTION_START, "selection,start", "") \
cmd(SIG_TEXT_SET_DONE, "text,set,done", "") \
cmd(SIG_THEME_CHANGED, "theme,changed", "") \
cmd(SIG_UNDO_REQUEST, "undo,request", "")
cmd(SIG_UNDO_REQUEST, "undo,request", "") \
cmd(SIG_REJECTED, "rejected", "")
ELM_PRIV_ENTRY_SIGNALS(ELM_PRIV_STATIC_VARIABLE_DECLARE);
@ -4700,12 +4701,13 @@ elm_entry_filter_limit_size(void *data,
EAPI void
elm_entry_filter_accept_set(void *data,
Evas_Object *entry __UNUSED__,
Evas_Object *entry,
char **text)
{
int read_idx, last_read_idx = 0, read_char;
Elm_Entry_Filter_Accept_Set *as = data;
Eina_Bool goes_in;
Eina_Bool rejected = EINA_FALSE;
const char *set;
char *insert;
@ -4803,6 +4805,10 @@ inserting:
memcpy(insert, *text + last_read_idx, size);
insert += size;
}
else
{
rejected = EINA_TRUE;
}
if (read_char)
{
@ -4811,6 +4817,8 @@ inserting:
}
}
*insert = 0;
if (rejected)
evas_object_smart_callback_call(entry, SIG_REJECTED, NULL);
}
EAPI Eina_Bool

View File

@ -248,6 +248,7 @@
* @li "text,set,done": Whole text has been set to the entry.
* @li "theme,changed": Called when the theme is changed.
* @li "undo,request": Called on undo request.
* @li "rejected": Called when some of inputs are rejected by the filter. (since 1.9)
*
* Default content parts of the entry items that you can use for are:
* @li "icon" - An icon in the entry