cancel
Showing results for 
Search instead for 
Did you mean: 

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

wired
Senior III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

Osman SOYKURT
ST Software Developer | TouchGFX

View solution in original post

8 REPLIES 8
Osman SOYKURT
ST Employee

Hello wired,

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

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
Osman SOYKURT
ST Employee

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

Osman SOYKURT
ST Software Developer | TouchGFX

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.

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

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

Osman SOYKURT
ST Software Developer | TouchGFX

@Osman SOYKURT​, I guess you're saying that there is no way to identify that an item has been selected using a touch in a ScrollWheel? I would really prefer that it worked as described in the documentation rather than changing the documentation to match its behavior. As I said, the two callbacks are currently redundant, since they always return the same item at the same time. I'd like to offer a suggestion that there be a boolean method added to disable automatic selection of the animated-to item. If disabled, it would require the user to select an item by a touch. It could be enabled by default for backward compatibility. This would allow for more use cases for the ScrollWheel. One does not always want to take an action upon the highlighted item, especially when multiple swipes are required to traverse the contained items.

I will have to try a ScrollList now, although it does not provide the benefit of having a built-in mechanism to highlight the selected item. Hopefully it will not behave the same way.

I was able to modify my simple ScrollWheel example to add a scroll list. It does have the ItemSelected callback operating as documented. I was also able to highlight the selected element, so I think switching to the ScrollList is my only option.

Hello wired,

Great to hear that the ScrollList made the job!

Yes no worries, we will make it work as described in the documentation.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX