Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3297] iOS: Ti.UI.Switch click event does not fire

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2016-08-28T23:00:53.000+0000
Affected Version/sRelease 3.0.0, Release 3.1.0, Release 3.2.0
Fix Version/sn/a
ComponentsiOS
Labelsapi, parity, supportTeam
ReporterPaul Dowsett
AssigneeIngo Muschenetz
Created2011-04-15T03:41:39.000+0000
Updated2017-03-20T21:26:10.000+0000

Description

Environment: iOS 4.2, Ti SDK 1.6, Mac OS

In the above environment, the switch click event does not fire. The following code demonstrates the issue. The same code works fine on Android.

Ti.UI.setBackgroundColor('#226');
 
var win1 = Ti.UI.createWindow({  
    title:'this is window1',
    backgroundColor:'#fff'
});
 
var switch1 = Ti.UI.createSwitch({
    value:false,
    top:30
});
 
switch1.addEventListener('click', function(e) {
    Ti.API.info('the switch has been switched to: '+e.source.value);
});
 
win1.add(switch1);
win1.open();

Comments

  1. Fred Spencer 2012-04-05

    Though it's understood on iOS that this is possibly working as intended, the issue is parity.
  2. Junaid Younus 2012-09-05

    Tested on a Samsung Galaxy S2 and the iOS simulator using TiSDK 2.2.0v20120904101713, issue still valid.
       Ti.UI.setBackgroundColor('#226');
        
       var win1 = Ti.UI.createWindow({  
           title:'this is window1',
           backgroundColor:'#fff'
       });
        
       var switch1 = Ti.UI.createSwitch({
           value:false,
           top:30
       });
        
       switch1.addEventListener('click', function(e) {
           alert('the switch has been switched to: '+e.source.value);
       });
        
       win1.add(switch1);
       win1.open();
       
  3. Shameer Jan 2013-05-08

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 iOS iPhone Simulator: iOS SDK version: 6.0
  4. Hans Knöchel 2016-08-28

    This issue is invalid. Switch-controls are not supposed to fire click-events for changed values. As the [docs say](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Switch-event-change), the change event is supposed to handle the changed values.
  5. Ingo Muschenetz 2016-08-29

    [~hansknoechel] Could we hide the click event in the docs? If it doesn't do anything, should it be documented?
  6. Hans Knöchel 2016-08-29

    Added the docs-phrase [here](https://github.com/appcelerator/titanium_mobile/pull/8284) by referencing the TiUIView docs and adding a note about using the correct event.
  7. Lee Morris 2017-03-20

    Closing ticket as invalid.

JSON Source