improve combobox

This commit is contained in:
xianjimli 2020-01-11 14:40:24 +08:00
parent 06d03cf9bf
commit 7b2eea9cbd
2 changed files with 22 additions and 1 deletions

View File

@ -289,11 +289,31 @@ static ret_t combo_box_on_event(widget_t* widget, event_t* e) {
}
break;
}
case EVT_POINTER_DOWN: {
combo_box->pressed = TRUE;
break;
}
case EVT_POINTER_DOWN_ABORT: {
combo_box->pressed = FALSE;
break;
}
case EVT_POINTER_UP: {
if (widget->target == NULL && edit->readonly && combo_box->pressed) {
combo_box_active(widget);
return RET_STOP;
}
combo_box->pressed = FALSE;
}
default:
break;
}
ret = edit_on_event(widget, e);
edit_set_cursor(WIDGET(edit), 0);
if(edit->readonly) {
edit_set_cursor(WIDGET(edit), 0);
}
return ret;
}

View File

@ -197,6 +197,7 @@ typedef struct _combo_box_t {
/*private*/
str_t text;
bool_t pressed;
combo_box_option_t* option_items;
combo_box_custom_open_popup_t open_popup;
} combo_box_t;