forked from enlightenment/efl
elm/check: fix emission of legacy "changed" callback
legacy "check" and "toggle" widgets operate differently: * check emits only the "toggle" event * toggle emits "toggle", "on", "off" legacy also must not emit events when the widget's state is changed programmatically to handle this effectively, check whether the event has been emitted for each state when the signal is emitted from the theme, and track this for subsequent uses to ensure that exactly one event is triggered when it should be Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9831
This commit is contained in:
parent
011022ae1b
commit
7767ce884a
|
@ -50,6 +50,25 @@ static const Elm_Action key_actions[] = {
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_legacy_event(Eo *obj)
|
||||||
|
{
|
||||||
|
EFL_UI_CHECK_DATA_GET(obj, pd);
|
||||||
|
if (pd->selected)
|
||||||
|
{
|
||||||
|
if (pd->legacy_changed_emitted_select) return;
|
||||||
|
pd->legacy_changed_emitted_select = EINA_TRUE;
|
||||||
|
pd->legacy_changed_emitted_unselect = EINA_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pd->legacy_changed_emitted_unselect) return;
|
||||||
|
pd->legacy_changed_emitted_unselect = EINA_TRUE;
|
||||||
|
pd->legacy_changed_emitted_select = EINA_FALSE;
|
||||||
|
}
|
||||||
|
evas_object_smart_callback_call(obj, "changed", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_activate(Evas_Object *obj)
|
_activate(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -97,8 +116,7 @@ _activate(Evas_Object *obj)
|
||||||
// "efl,state,check,on" or "efl,state,check,off" for eo-api
|
// "efl,state,check,on" or "efl,state,check,off" for eo-api
|
||||||
efl_ui_selectable_selected_set(obj, !efl_ui_selectable_selected_get(obj));
|
efl_ui_selectable_selected_set(obj, !efl_ui_selectable_selected_get(obj));
|
||||||
if (elm_widget_is_legacy(obj))
|
if (elm_widget_is_legacy(obj))
|
||||||
evas_object_smart_callback_call(obj, "changed", NULL);
|
_check_legacy_event(obj);
|
||||||
|
|
||||||
if (_elm_config->atspi_mode)
|
if (_elm_config->atspi_mode)
|
||||||
efl_access_state_changed_signal_emit(obj,
|
efl_access_state_changed_signal_emit(obj,
|
||||||
EFL_ACCESS_STATE_TYPE_CHECKED,
|
EFL_ACCESS_STATE_TYPE_CHECKED,
|
||||||
|
@ -231,6 +249,8 @@ _on_check_off(void *data,
|
||||||
Evas_Object *obj = data;
|
Evas_Object *obj = data;
|
||||||
|
|
||||||
_flush_selected(obj, EINA_FALSE);
|
_flush_selected(obj, EINA_FALSE);
|
||||||
|
if (elm_widget_is_legacy(obj))
|
||||||
|
_check_legacy_event(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -242,6 +262,8 @@ _on_check_on(void *data,
|
||||||
Evas_Object *obj = data;
|
Evas_Object *obj = data;
|
||||||
|
|
||||||
_flush_selected(obj, EINA_TRUE);
|
_flush_selected(obj, EINA_TRUE);
|
||||||
|
if (elm_widget_is_legacy(obj))
|
||||||
|
_check_legacy_event(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -28,6 +28,8 @@ struct _Efl_Ui_Check_Data
|
||||||
{
|
{
|
||||||
Eina_Bool *statep;
|
Eina_Bool *statep;
|
||||||
Eina_Bool selected;
|
Eina_Bool selected;
|
||||||
|
Eina_Bool legacy_changed_emitted_unselect : 1;
|
||||||
|
Eina_Bool legacy_changed_emitted_select : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue