input: show cancel button instead of backarrow
Cancel is currently not null when restoring from mnemonic.
@@ -92,6 +92,7 @@ typedef struct {
component_t* title_component;
component_t* trinary_char_component;
component_t* confirm_component;
+ component_t* cancel_component;
component_t* left_arrow_component;
component_t* keyboard_switch_component;
} data_t;
@@ -209,9 +210,10 @@ static void _render(component_t* component)
}
if (!confirm_gesture_active) {
if (data->string_index != 0 ||
- trinary_input_char_in_progress(data->trinary_char_component) ||
- data->cancel_cb != NULL) {
+ trinary_input_char_in_progress(data->trinary_char_component)) {
data->left_arrow_component->f->render(data->left_arrow_component);
+ } else if (data->cancel_component != NULL) {
+ data->cancel_component->f->render(data->cancel_component);
}
if (data->keyboard_switch_component != NULL) {
data->keyboard_switch_component->f->render(data->keyboard_switch_component);
@@ -323,9 +325,6 @@ static void _on_event(const event_t* event, component_t* component)
data->target_x = SCROLL_RIGHT_LIMIT - string_width;
// data->target_x += MIN(SCREEN_WIDTH - SCROLL_RIGHT_LIMIT, string_width);
}
- } else if (data->cancel_cb != NULL) {
- data->cancel_cb(data->cancel_callback_param);
- data->cancel_cb = NULL;
}
_set_alphabet(component);
_set_can_confirm(component);
@@ -335,6 +334,15 @@ static void _on_event(const event_t* event, component_t* component)
}
}
+static void _cancel(component_t* cancel_button)
+{
+ component_t* component = cancel_button->parent;
+ data_t* data = (data_t*)component->data;
+ if (data->cancel_cb != NULL) {
+ data->cancel_cb(data->cancel_callback_param);
+ }
+}
+
static void _letter_chosen(component_t* trinary_char, char chosen)
{
component_t* trinary_input_string = trinary_char->parent;
@@ -414,6 +422,10 @@ static component_t* _create(
component->position.top = 0;
component->position.left = 0;
+ if (cancel_cb != NULL) {
+ data->cancel_component = icon_button_create(top_slider, ICON_BUTTON_CROSS, _cancel);
+ ui_util_add_sub_component(component, data->cancel_component);
+ }
data->left_arrow_component = left_arrow_create(top_slider, component);
ui_util_add_sub_component(component, data->left_arrow_component);
