table field: add onSelected()
This commit is contained in:
committed by
Raphael Coeffic
parent
14fea89118
commit
ae6f7b55d3
+7
-12
@@ -65,17 +65,21 @@ void TableField::clicked(lv_event_t *e)
|
|||||||
TableField* tf = (TableField*)lv_obj_get_user_data(target);
|
TableField* tf = (TableField*)lv_obj_get_user_data(target);
|
||||||
if (!tf) return;
|
if (!tf) return;
|
||||||
|
|
||||||
|
uint16_t row;
|
||||||
|
uint16_t col;
|
||||||
|
lv_table_get_selected_cell(target, &row, &col);
|
||||||
|
if (row == LV_TABLE_CELL_NONE || col == LV_TABLE_CELL_NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||||
// Encoder send VALUE_CHANGED when selection changes
|
// Encoder send VALUE_CHANGED when selection changes
|
||||||
tf->adjustScroll();
|
tf->adjustScroll();
|
||||||
|
tf->onSelected(row, col);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise it's a click
|
// Otherwise it's a click
|
||||||
if (lv_group_get_editing((lv_group_t*)lv_obj_get_group(target))
|
if (lv_group_get_editing((lv_group_t*)lv_obj_get_group(target))
|
||||||
|| indev_type == LV_INDEV_TYPE_POINTER) {
|
|| indev_type == LV_INDEV_TYPE_POINTER) {
|
||||||
uint16_t row;
|
|
||||||
uint16_t col;
|
|
||||||
lv_table_get_selected_cell(target, &row, &col);
|
|
||||||
|
|
||||||
tf->onPress(row, col);
|
tf->onPress(row, col);
|
||||||
} else {
|
} else {
|
||||||
@@ -261,15 +265,6 @@ void TableField::onEvent(event_t event)
|
|||||||
onKeyPress();
|
onKeyPress();
|
||||||
selectNext(-1);
|
selectNext(-1);
|
||||||
}
|
}
|
||||||
// else if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
|
||||||
// onKeyPress();
|
|
||||||
|
|
||||||
// uint16_t row;
|
|
||||||
// uint16_t col;
|
|
||||||
// lv_table_get_selected_cell(lvobj, &row, &col);
|
|
||||||
|
|
||||||
// onPress(row, col);
|
|
||||||
// }
|
|
||||||
else {
|
else {
|
||||||
Window::onEvent(event);
|
Window::onEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -48,6 +48,7 @@ class TableField : public Window
|
|||||||
void selectNext(int16_t dir);
|
void selectNext(int16_t dir);
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
|
|
||||||
|
virtual void onSelected(uint16_t row, uint16_t col) {}
|
||||||
virtual void onDrawBegin(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc) {}
|
virtual void onDrawBegin(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc) {}
|
||||||
virtual void onDrawEnd(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc) {}
|
virtual void onDrawEnd(uint16_t row, uint16_t col, lv_obj_draw_part_dsc_t* dsc) {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user