[TIMOB-8490] IOS: Ti.UI.Button does not act as a true View group.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Won't Do |
Resolution Date | 2020-01-10T18:03:19.000+0000 |
Affected Version/s | Release 3.1.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | reprod |
Reporter | Vishal Duggal |
Assignee | Unknown |
Created | 2012-04-02T14:38:49.000+0000 |
Updated | 2020-01-10T18:03:19.000+0000 |
Description
Found this bug when doing a FR of PR 1892 (TIMOB-7841).
Use the code below to test.
Current Behavior:
Label click event handler never gets called. But the button event handler always gets called when button is clicked.
Expected behavior:
Label and button event handler should be called when label is clicked. Button event handler should be called when when button is clicked outside the label.
var win = Ti.UI.createWindow({
backgroundColor:"white"
});
var button = Ti.UI.createButton({
width:200,
height:200,
enabled:true,
backgroundImage:"blue.png",
backgroundColor:"red"
})
var btnLabel = Ti.UI.createLabel({
text:"I am button",
backgroundColor:"green"
})
button.add(btnLabel);
btnLabel.addEventListener('click',function(e){
Ti.API.info("LABEL CLICKED "+e.source);
})
button.addEventListener('click',function(e){
Ti.API.info("BUTTON CLICKED "+e.source);
})
var btnstate = true;
var stateChange = Ti.UI.createButton({
title:"Click Me",
width:Ti.UI.FILL,
height:40,
bottom:10
})
stateChange.addEventListener('click',function(){
if (btnstate === true)
{
Ti.API.info("Disabling Button");
button.setEnabled(false);
btnstate = false;
}
else
{
Ti.API.info("Enabling Button");
button.setEnabled(true);
btnstate = true;
}
})
win.add(button);
win.add(stateChange);
win.open();
Attachments
File | Date | Size |
---|---|---|
blue.png | 2012-04-02T14:38:49.000+0000 | 2133 |
In looking into this, there is a difficult quandary on this. The issue is hitTest, which determines where the click event goes. Because the label has clickEnabled false by default. The catch is that if this is fixed, this means that the label would suppress the button hilighting since it would steal the click event instead. Proposal in the long run is to do away with button as a view group. It was a hideous hack to begin with due to some old iOS limitations, and now that you can modify the label and image views that are natively inside UIButton, we should do that instead.
Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
I am able to reproduce this issue with the following environment; iPhone 7 (10.2) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170620103414 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131
This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.