Problem
if you have a Button with a touchstart event it can look disabled if you call setEnabled(true) after the button is clicked. If they use a touchend, or click event then this issue is not present or if I use the 2.1.3.GA sdk then this issue does not occur with the touchstart event.
To reproduce
1. Install this app to a android device.
2. Launch ADB so you can see when the buttons are pressed.
3. Click Button 1, watch the logs to verify the button was clicked.
4. Click Enable Button 1
5. Notice that Button 1 is now in a depressed state.
6. Click on Button 1, notice it clicked and is now in a enabled state
7. Click Enable BUtton
8. Notice its back to the depressed state.
== app.js ==
var view = require('FirstView')();
var win = Ti.UI.createWindow({
backgroundColor: "white"
});
win.add(view);
win.open();
== FirstView.js ==
//FirstView Component Constructor
function FirstView() {
var self = Ti.UI.createView();
var defaults = {
enabled: true,//me
title : "Button 1",
top : 20,
width : 400,
height : 200,
backgroundTopCap : 50,
backgroundLeftCap : 50,
color : "#2C4471",
selectedColor : "#2C4471",
font : {
"fontSize" : "16dp",
"fontFamily" : "HelveticaNeue-Bold",
"fontWeight" : "bold"
},
backgroundImage : '/global-btn-up.png',
backgroundSelectedImage : '/global-btn-down.png',
shadow : {
shadowRadius : 4,
shadowOpacity : 0.2,
shadowOffset : {
x : 0,
y : 0
}
}
}
var button = Titanium.UI.createButton(defaults);
self.add(button);
button.addEventListener('touchstart', function() {
button.setEnabled(false);
Ti.API.info("[INFO] [Button 1 clicked!!]");
});
var button2 = Titanium.UI.createButton(defaults);
button2.top = 260;
button2.title = "Enable Button 1";
self.add(button2);
button2.addEventListener('touchstart', function() {
button.setEnabled(true);
Ti.API.info("[INFO] [Button 2 clicked!!]");
});
return self;
}
module.exports = FirstView;
I have logged my findings
This looks like an Android issue where the state is messed up if the button is disabled during touch event. One workaround could be to use 'touchend' instead of 'touchstart'
It appears that it worked with a previous Titanium SDK version. Can you reproduce this issue with a native application? If yes, can we have a workaround for Titanium SDK?