Description
When scrolled down to the end of table (or list), I’d like to get an event.
I used **LV_EVENT_SCROLL_END**
, but it all happened when I scrolled up or scrolled down to the end. How to get the event only when scrolled down?
When scrolled down to the end of table (or list), I’d like to get an event.
I used **LV_EVENT_SCROLL_END**
, but it all happened when I scrolled up or scrolled down to the end. How to get the event only when scrolled down?
You can check the scroll direction in the event with
if(lv_indev_get_scroll_dir(lv_indev_get_act()) == LV_DIR_BOTTOM)
{
...
}
I tried it, but only the LV_DIR_VER
event is occurred.
static void table_event_cb(lv_event_t * event)
{
lv_event_code_t code = lv_event_get_code(event);
if(lv_indev_get_scroll_dir(lv_indev_get_act()) == LV_DIR_BOTTOM )
{
if(code == LV_EVENT_SCROLL_END) {
...
}
}
else if(lv_indev_get_scroll_dir(lv_indev_get_act()) == LV_DIR_VER )
{
...
}
}
lv_obj_add_event_cb(win_content, table_event_cb, LV_EVENT_ALL, NULL);
Ah, you are right.
lv_point_t p;
lv_indev_get_vect(lv_indev_get_act(), &p);
tells the difference between the last and current point of the input device. You can check the sign of p.y
the decide the scroll direction.
That’s great. It works
lv_point_t p;
lv_indev_get_vect(lv_indev_get_act(), &p);
if(p.y < 0)
{
if(code == LV_EVENT_SCROLL_END) {
...
}
}