Lv_page_on_edge() with "delay"?

Hello,

I have two buttons which are supposed to scroll an lv_page object. In addition, those buttons should only be enabled, when the page can be scrolled to the specified direction.

So I go like this:

void update_updn (void)
{
    if (lv_page_on_edge (the_page, LV_PAGE_EDGE_TOP))
        disable_up_button ();
    else
        enable_up_button ();

    if (lv_page_on_edge (the_page, LV_PAGE_EDGE_BOTTOM))
        disable_dn_button ();
    else
        enable_dn_button ();
}

void gui_menu_up (lv_obj_t *btn, lv_event_t evt)
{
    lv_page_scroll_ver (menu_page, -70);
    update_updn();
}

void btn_dn_cb (lv_obj_t *btn, lv_event_t evt)
{
    lv_page_scroll_ver (menu_page, 70);
    update_updn();
}

Sorry, I sent the previous message too early. So here’s the rest:

For some reason, lv_page_on_edge() returns the information one clock too late.

For example: when scrolling to the top, it returns “false”. Only on the next attempt to scroll further, it returns “true”.

The other way around, the same happens: when scrolling down so that the second entry is on top, I get still “true”. Only when scrolling to the THIRD entry, I get “false”.

Do I need to do some sort of refresh to “update” the page object to the current state?

So here’s a more complete example to demonstrate the problem:

static lv_obj_t *menu_page=NULL;
static lv_obj_t *up_btn;
static lv_obj_t *dn_btn;

static void update_updn (void)
{
    if (lv_page_on_edge (menu_page, LV_PAGE_EDGE_TOP))
        lv_btn_set_state (up_btn, LV_BTN_STATE_DISABLED);
    else
        lv_btn_set_state (up_btn, LV_BTN_STATE_RELEASED);

    if (lv_page_on_edge (menu_page, LV_PAGE_EDGE_BOTTOM))
        lv_btn_set_state (dn_btn, LV_BTN_STATE_DISABLED);
    else
        lv_btn_set_state (dn_btn, LV_BTN_STATE_RELEASED);

    printf ("ev top-edge:%d bottom-edge:%d\r\n",
               lv_page_on_edge (menu_page, LV_PAGE_EDGE_TOP),
               lv_page_on_edge (menu_page, LV_PAGE_EDGE_BOTTOM));
}

static void scroll_up (lv_obj_t *btn, lv_event_t event)
{
    switch (event) {
    case LV_EVENT_PRESSED: /* FALL THRU */
    case LV_EVENT_LONG_PRESSED_REPEAT:
        lv_page_scroll_ver (menu_page, 160);
        update_updn ();
        break;
    }
}

static void scroll_dn (lv_obj_t *btn, lv_event_t event)
{
    switch (event) {
    case LV_EVENT_PRESSED: /* FALL THRU */
    case LV_EVENT_LONG_PRESSED_REPEAT:
        lv_page_scroll_ver (menu_page, -160);
        update_updn ();
        break;
    }
}

void test_screen (void)
{
    lv_style_t disabled;
    lv_style_init (&disabled);
    lv_style_set_bg_color     (&disabled, LV_BTN_STATE_DISABLED, LV_COLOR_RED);
    lv_style_set_border_color (&disabled, LV_BTN_STATE_DISABLED, LV_COLOR_RED);

    menu_page = lv_page_create (lv_scr_act(), NULL);
    lv_obj_set_size (menu_page, 350, 430);
    lv_obj_align    (menu_page, NULL, LV_ALIGN_CENTER, 0, 0);

    lv_page_set_scrl_layout (menu_page, LV_LAYOUT_COLUMN_MID);

    for (int i=0; i<10; i++) {
        lv_obj_t *menu_btn = lv_btn_create (menu_page, NULL);
        lv_obj_set_height (menu_btn, 60);

        lv_obj_t *label = lv_label_create (menu_btn, NULL);
        char text[100];
        sprintf (text, "Menu-entry %d", i);
        lv_label_set_text (label, text);
    }

    up_btn = lv_btn_create (lv_scr_act(), NULL);
    dn_btn = lv_btn_create (lv_scr_act(), NULL);
    lv_obj_align (up_btn, menu_page, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
    lv_obj_align (dn_btn, menu_page, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
    lv_obj_set_event_cb (up_btn, scroll_up);
    lv_obj_set_event_cb (dn_btn, scroll_dn);
    lv_obj_add_style (up_btn, LV_BTN_PART_MAIN, &disabled);
    lv_obj_add_style (dn_btn, LV_BTN_PART_MAIN, &disabled);

    lv_obj_t *up_lbl = lv_label_create (up_btn, NULL);
    lv_obj_t *dn_lbl = lv_label_create (dn_btn, NULL);
    lv_label_set_text (up_lbl, "Up");
    lv_label_set_text (dn_lbl, "Down");
}

BTW: for some reason the up/down buttons ignore the style setting which I have introduced to make the visualization more visible.

Any ideas what might be wrong here?