cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple calls to ...UpdateCenterItem when moving a scroll List, but last value of itemIndex is not the center item.

RWebe.7
Associate II

I've implemented a scroll list, following the documentation at https://touchgfx.zendesk.com/hc/en-us/sections/201785662-Tutorial-4-Creating-a-Scroll-Wheel-with-custom-behavior. Generally, it works. I have a function to update non-center items, and one to update center items.

The problem is, when I slide the scroller, I get multiple calls to the "UpdateCenterItem" and UpdateItem" functions. The first call is to UpdateCenterItem with the itemIndex I expect. Then, not surprisingly, there are calls to UpdateItem. The strange thing is, UpdateCenterItem is called several times, with itemIndex values I don't expect, and these are not the ones shown as the center item on the GUI. Also, UpdateItem is called with the itemIndex that is the highlighted center item. It seems there are extra calls to these functions but they're not being updated on the GUI.

If it was just the affect of the slider extending beyond moving 1 location, I could see multiple calls, but then the last time UpdateCenterItem is called, that value of itemIndex should be the item in the center.

When UpdaetCenterItem is called, I call

item.UpdateText(itemIndex);

which has

	Unicode::snprintf(text_Number_SelectedBuffer, TEXT_NUMBER_SELECTED_SIZE, "%d", value);
	text_Number_Selected.setWildcard(text_Number_SelectedBuffer);
	text_Number_Selected.invalidate();

I have a similar UpdateText for the non-center items. Is this not the correct way to update the center item in a scroll list? It seems like the GUI isn't taking some updates?

1 ACCEPTED SOLUTION

Accepted Solutions
RWebe.7
Associate II

Maybe I gave too much detail, making the problem seem more difficult than it was. The short answer is, scroll wheel items have a function for retrieving the index of the selected entry. Why I couldn't find this before, I don't know.

See https://www.touchgfx.com/documentation/html/classtouchgfx_1_1_scroll_wheel_base_ad540b777ff5c1425b673d31bcfb78763.html#ad540b777ff5c1425b673d31bcfb78763

View solution in original post

2 REPLIES 2
RWebe.7
Associate II

The repeated updates to the center item may be normal. I'm guessing that the reason the GUI isn't showing the later calls because those items may be slightly in the center area for a moment, but end up being outside when the scrolling is done. I just want to make sure I'm not missing something.

What I really need is a way to get the current center item from the scroll wheel (sorry I mentioned list above; I'm implementing the scroll wheel). Then, when the user saves, I can get the settings.

I see this function,  getSelectedItemOffset(), in the API, but it gives the offset in pixels. What I need is the value of itemIndex. I don't see that.

RWebe.7
Associate II

Maybe I gave too much detail, making the problem seem more difficult than it was. The short answer is, scroll wheel items have a function for retrieving the index of the selected entry. Why I couldn't find this before, I don't know.

See https://www.touchgfx.com/documentation/html/classtouchgfx_1_1_scroll_wheel_base_ad540b777ff5c1425b673d31bcfb78763.html#ad540b777ff5c1425b673d31bcfb78763