Skip to main content
wired
Senior II
August 25, 2022
Solved

Why is the ItemSelectedCallback for a scroll wheel not behaving as described in the API?

  • August 25, 2022
  • 8 replies
  • 2624 views

I have a scroll wheel containing a dynamically-created list of items that I would like to be able to traverse using swiping or dragging motions. When the desired item is in view, I want the user to be able to select it with a touch press, just like you would with a button.

According to the API documentation, the public function setItemSelectedCallback is supposed to be called when the selected item is clicked. The setAnimateToCallback is supposed to be called when the scroll wheel animates to a new item. I have set both of these up, but I get both callbacks every time the AnimatedTo item changes. In other words, I can swipe down on my list, and when the animation stops, I always get both callbacks, even though I did not click on any item. This seems like improper behavior.

How do I get a 'clicked-on' item? I do realize that the 'clicked-on' item will be animated to become the selected item. I just don't want to get the SelectedItemCallback from a swipe or a drag.

FYI, I have modified the Scroll Wheel in the ScrollList Example provided by TouchGFX Designer to test this.

This topic has been closed for replies.
Best answer by Osman SOYKURT

Hello wired,

Yes you're correct, there's a confusion in the documentation. I've talked about it to my colleagues, it's on their table now. I can't promise you a fix for the next release, but I'll keep you in touch when I'll have more info about it.

Did you tried to use a Scroll List instead ?

/Osman

8 replies

Osman SOYKURT
ST Technical Moderator
August 29, 2022

Hello wired,

Thanks for your question, I'll investigate on that and get back to you later with conclusions.

/Osman

ST Software Developer | TouchGFX
Osman SOYKURT
ST Technical Moderator
August 29, 2022

Hi again,

To be sure to understand what you want, you would like to call the "setItemSelectedCallback " when you click on an item on your scroll wheel right ? If the element you clicked is not the one in the center, the "setAnimateToCallback " needs to be called too ? If it's already the one in the middle, I suppose that you don't want to call the "setAnimateToCallback" isn't it ? And lastly, if you drag your scrollwheel, you don't want to call the "setItemSelectedCallback ", only the "setAnimateToCallback" should be called, am I right ?

/Osman

ST Software Developer | TouchGFX
wired
wiredAuthor
Senior II
August 29, 2022

Yes, Osman, you are correct. I expect to get the AnimateTo callback any time the scroll wheel is moved and 'lands on' a different item. I do not expect to get the Selected Item callback unless I have chosen that item from the list. It could either be the 'selected item', i.e. the one that may have different formatting, or it may be another item visible in the list that then also gets animated to and then becomes the highlighted item. IMO, there is no point in having the SelectedItem callback if it simply mirrors the AnimateTo callback.

I'm not in the office until tomorrow, but one thing I will try is removing the 'Selected Item' separate formatting for one of the list elements. I was using it more as a 'highlighted' element rather than the selected element. Perhaps when this option is chosen the software always issues the SelectedItem callback when the highlighted item changes. I still disagree that the SelectedItem callback should be used for this purposes because that same information can always be retrieved using the AnimateTo callback, but I guess I can see that it might be implemented that way. However, the description in the API would be incorrect, because it clearly states a click is needed. The way it is currently implemented, swiping through a large list could result in many SelectedItem callbacks before the desired element is shown onscreen.

wired
wiredAuthor
Senior II
August 30, 2022

@Osman SOYKURT​, I deselected the Selected Style Template in the scroll wheel properties, but the behavior is unchanged.