Rendering issue on long ddlists

Description

While scrolling a long ddlist using the keyboard the ddlist jumps between the underlying page position and the position of the currently selected element (Sorry for the bad description i have added a gif for better explanation).

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

I am using the Visual Studio Simulator (LVGL v6.1.1)

What do you experience?

See description

What do you expect?

Always render the ddlist so it displays the current page position or the region around the selected element.

Code to reproduce

screen = lv_obj_create(NULL, NULL);
lv_scr_load(screen);
lv_group_t * grp = lv_group_create();
lv_indev_set_group(kb_indev, grp);
	
lv_obj_t * dd = lv_ddlist_create(screen, NULL);
lv_ddlist_set_draw_arrow(dd, 1);
lv_ddlist_set_options(dd, "Option1\nOption2\nOption3\nOption4\nOption5\nOption6\nOption7\nOption8\nOption9\nOption10\nOption11\nOption12\nOption13\nOption14\nOption15\nOption16\nOption17\nOption18\nOption19\nOption20\nOption21\nOption22\nOption23\nOption24\nOption25\nOption26\nOption27\nOption28\nOption29\nOption30\nOption31\nOption32\nOption33\nOption34\nOption35\nOption36\nOption37\nOption38\nOption39\nOption40\nOption41\nOption42\nOption43\nOption44\nOption45\nOption46\nOption47\nOption48\nOption49\nOption50\nOption51\nOption52\nOption53\nOption54\nOption55\nOption56\nOption57\nOption58\nOption59\nOption60\nOption61\nOption62\nOption63\nOption64\nOption65\nOption66\nOption67\nOption68\nOption69\nOption70\nOption71\nOption72\nOption73\nOption74\nOption75\nOption76\nOption77\nOption78\nOption79\nOption80\nOption81\nOption82\nOption83\nOption84\nOption85\nOption86\nOption87\nOption88\nOption89\nOption90\nOption91\nOption92\nOption93\nOption94\nOption95\nOption96\nOption97\nOption98\nOption99\nOption100\nOption101\nOption102\nOption103\nOption104\nOption105\nOption106\nOption107\nOption108\nOption109\nOption110\nOption111\nOption112\nOption113\nOption114\nOption115\nOption116\nOption117\nOption118\nOption119\nOption120\nOption121\nOption122\nOption123\nOption124\nOption125\nOption126\nOption127\nOption128\nOption129\nOption130\nOption131\nOption132\nOption133\nOption134\nOption135\nOption136\nOption137\nOption138\nOption139\nOption140\nOption141\nOption142\nOption143\nOption144\nOption145\nOption146\nOption147\nOption148\nOption149\nOption150\nOption151\nOption152\nOption153\nOption154\nOption155\nOption156\nOption157\nOption158\nOption159\nOption160\nOption161\nOption162\nOption163\nOption164\nOption165\nOption166\nOption167\nOption168\nOption169\nOption170\nOption171\nOption172\nOption173\nOption174\nOption175\nOption176\nOption177\nOption178\nOption179\nOption180\nOption181\nOption182\nOption183\nOption184\nOption185\nOption186\nOption187\nOption188\nOption189\nOption190\nOption191\nOption192\nOption193\nOption194\nOption195\nOption196\nOption197\nOption198\nOption199");
lv_ddlist_set_fix_height(dd, lv_obj_get_height_fit(screen));

lv_group_add_obj(grp, dd);

Screenshot and/or video

vlcsnap-2020-02-13-08h22m20s056

Solution

The problem seems to be in the lv_ddlist_signal function:

  • lv_page_signal is called which processes the key events and scrolls the page
  • later in lv_ddlist_signal it also processes the key events and tries to position the page so that it displays the current element (calls lv_ddlist_pos_current_option)

I found two possible solutions for this problem:

  • Do not call lv_page_signal when signal is of type ‘LV_SIGNAL_CONTROL’ and the key is one of the arrow keys.
    This way the currently selected element is always visible.
  • Do not call lv_ddlist_pos_current_option.
    This way the current page position is visible.

I can create a PR for this issue but i am not sure which of the two solutions should be applied, in my code i filter the calls to lv_page_signal.

I think the first solution you suggested makes more sense (don’t let the key events reach lv_page_signal).