Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27977] TiAPI: Add "isTrusted" property to Ti.UI.Slider "change" event

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2020-08-06T14:33:02.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.1.0
ComponentsAndroid, iOS
Labelsandroid, event, iOS, slider
ReporterMichael Gangolf
AssigneeJoshua Quick
Created2020-05-20T10:50:09.000+0000
Updated2021-02-17T05:40:13.000+0000

Description

Component: Ti.UI.Slider Platform: Android At the moment it is not possible to differentiate between a "user slide" and a "change of the value by code" inside the change event. There is already a fromUser parameter inside the listener: https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUISlider.java#L315 Exposing that value inside the event: https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUISlider.java#L361 and changing the calls to that function to "onProgressChanged(seekBar, curPos, false);" (last parameter false) would only output true if the slider was dragged by the user. PR and Test case will follow

Comments

  1. Michael Gangolf 2020-05-20

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11717
  2. Joshua Quick 2020-06-20

    [~michael], perhaps a better solution would be that a "change" event should *+NOT+* be fired when setting the Slider "value" property programmatically? This is how TextField and TextArea works. Although doing it this way may qualify it as a breaking-change. _(Your approach is not a breaking-change.)_ I just checked Picker and it fire a "change" event when changing its selection programmatically too.
  3. Michael Gangolf 2020-06-20

    Perhaps the non breaking change for now and then make it behave the same way like TextFields in a later SDK?
  4. Joshua Quick 2020-06-22

    After putting some more thought into this, I agree with you. I don't think we should make a breaking-change to this. It's not "wrong" of it to fire a change event when the value is changed programmatically. In fact, many UI frameworks work this way. When developing for the web, events have an isTrusted boolean property which is set true if it was generated by end-user interaction. Perhaps we should do the same? It's not the best property name, but it is a standard name that web developers are familiar with. What do you think? https://developer.mozilla.org/docs/Web/API/Event/isTrusted
  5. Marian Kucharcik 2020-06-23

    Guys I don't get it...I was finding solution on Ti.Slack about this, because Android returns this property natively and it is not exposed to Titanium app. That's it. I think that simple solution(already prepared by Michael) is the best - just expose that fromUser property and done...
  6. Joshua Quick 2020-06-23

    [~max87], Titanium is a cross-platform framework. What we implement on Android also needs to be implemented on iOS. And it's also preferred that we implement things the JavaScript way since Titanium appeals to web developers. Titanium's "event" object already replicates several several standard properties such as [type](https://developer.mozilla.org/en-US/docs/Web/API/Event/type) and [bubbles](https://developer.mozilla.org/en-US/docs/Web/API/Event/bubbles). We're talking about implementing this ticket via [isTrusted](https://developer.mozilla.org/docs/Web/API/Event/isTrusted) as well.
  7. Michael Gangolf 2020-06-23

    updated the PR and changed the parameter to "isTrusted". Added the value to the documentation, too
  8. Marian Kucharcik 2020-06-23

    @Joshua Quick I understand. What I meant was, that solution is already prepared(I think that it's not important if parameter is called fromUser or isTrusted, important is, that such a parameter is exposed to Ti developers). For iOS there is no such a parameter in native side(AFAIK). Strange is, that when I implemented this funcionality as custom, there was a performance issues and it was not working well. As I made changes to SDK and exposed fromUser, everything is okay. On the other side, iOS has no performance issues with custom parameter(original solution for Android).
  9. Samir Mohammed 2020-07-01

    FR Passed, waiting on Jenkins build.
  10. Christopher Williams 2020-07-01

    merged to master for 9.1.0 target
  11. Sohail Saddique 2020-08-06

    Fix verified on build 9.1.0.v20200804082025. Ticket closed.

JSON Source