How to disable the scroll animations of TableView

Important: unclear posts may not receive useful answers.

Description

I want to disable the scroll animations of TableView. I have referenced to the example " Tabs on the left, styling and no scrolling". As the example, a call back function is used to disable the scroll animations of TableView. The problem is that the event-parameter is null, and the scroll animations can not be disable via set the variable “time” of the event-parameter as zero.

Thank you for your suggest!

What MCU/Processor/Board and compiler are you using?

Visual Studio Simulator.

What LVGL version are you using?

v8.0

What do you want to achieve?

disable the scroll animations of TableView

What have you tried so far?

I have referenced to the example " Tabs on the left, styling and no scrolling". As the example, a call back function is used to disable the scroll animations of TableView.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static void scroll_begin_event(lv_event_t* e)
{
    /*Disable the scroll animations. Triggered when a tab button is clicked */
    if (lv_event_get_code(e) == LV_EVENT_SCROLL_BEGIN) {
        lv_anim_t* a = lv_event_get_param(e);
        if (a)  a->time = 0;
     
    }
}

void my_ui(void)
{
   lv_obj_t* tabview;
   tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 30); 
   lv_obj_add_event_cb(lv_tabview_get_content(tabview), scroll_begin_event,LV_EVENT_SCROLL_BEGIN, NULL);
   lv_obj_clear_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE);
   tab_ctrl = lv_tabview_add_tab(tabview, "CTRL");
   tab_file = lv_tabview_add_tab(tabview, "FILE");
   ...
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.
As the figure show, the variables of a(lv_anim_t* a = lv_event_get_param(e);) can not be read.


Hi,
Mmm, your code seems fine, it is works with me. Make sure that your callback wasn’t added to another object. Try changing the callback function name (scroll_begin_event) to any other name.

Thank you, I will try it!

Hi, I had the same problem and then I realised that my main function was called main.cpp and so the compiler was not happy with the type definitions.

An easy fix for me was to cast the type of the return value of the function by changing the following (in the callback function):

lv_anim_t * a = lv_event_get_param(e);
to…
lv_anim_t * a = (lv_anim_t *) lv_event_get_param(e);

it is a cheat but hey worked for me! :slight_smile: