2022-09-12 02:22 AM
Im using Scrollwheels on different screens. Wherever I move the selected Item to the middle of the list by increasing the SelectedItemOffset, Items above the selected Item (middle of the list) tend to disappear. As soon as I activate the Circular mode, everything runs fine.
Does anyone else had similiar behaviour? I tried to provoke this with the very similar ScrollWheel/List example, but there it is running fine.
I'm using the current TouchGFX 4.20.
Solved! Go to Solution.
2022-09-13 11:28 PM
I think I found the solution. I was looking at your code and didn't find anything different compared to mine. But looking at the Designer I noticed that I have set the Number of Items to 1 and you had 16. So I increased the value and now it's working. I thought this value is irrelevant, because the item count will be changed at runtime anyway.
Looking at the changes the code generator makes, this looks like a bug inside the TouchGFX lib when setting the Selected Item Offset to a value where no items exist at the moment of the function call (in the constructor of the parent screen/container):
swOutput.setNumberOfItems(1);
swOutput.setSelectedItemOffset(125);
vs.
swOutput.setNumberOfItems(10);
swOutput.setSelectedItemOffset(125);
2022-09-13 04:49 AM
I was using the SelectedItemOffset without circular mode on a ScrollWheel, and had no issues. I based my design off the ScrollWheel example. However, I was setting the item offset in Designer, not dynamically. Do you need/have an invalidate() after changing the offset?
2022-09-13 06:33 AM
Thanks for your reply. I'm setting the offset also in the Designer, so no need for invalidation.
2022-09-13 07:11 AM
2022-09-13 11:28 PM
I think I found the solution. I was looking at your code and didn't find anything different compared to mine. But looking at the Designer I noticed that I have set the Number of Items to 1 and you had 16. So I increased the value and now it's working. I thought this value is irrelevant, because the item count will be changed at runtime anyway.
Looking at the changes the code generator makes, this looks like a bug inside the TouchGFX lib when setting the Selected Item Offset to a value where no items exist at the moment of the function call (in the constructor of the parent screen/container):
swOutput.setNumberOfItems(1);
swOutput.setSelectedItemOffset(125);
vs.
swOutput.setNumberOfItems(10);
swOutput.setSelectedItemOffset(125);
2022-09-14 06:03 AM
Glad you got it worked out. Yes, there is weirdness if you exceed the number of items specified in the Designer at runtime. Perhaps there is a static memory allocation for the list based on this number. That is what I assumed when I encountered issues, so I made my Number of Items in the Designer greater than what I would ever need. It would be good if ST gave some input to this, as there is very little information about Number of Items in the documentation.
I was initially working with the Scroll Wheel like you and also had an offset, but since the scroll wheel cannot distinguish between an 'animated to' selection and a 'clicked on' selection (see my post here), I switched to a scroll list. I don't recall if it had the same issues with respect to the number of items.
2023-05-11 04:05 AM
Any news here from ST's side?