fix(android): Click events for invisible/touchEnabled:false views
JIRA: https://jira.appcelerator.org/browse/TIMOB-27893
Optional Description:
function onTouch(event) {
console.log("touch");
}
var window = Ti.UI.createWindow();
var childView = Ti.UI.createView({
backgroundColor: "blue",
width: 200,
height: 200
});
var btn = Ti.UI.createButton({
title: "toggle opacity",
bottom: 0,
left: 0
});
var btn2 = Ti.UI.createButton({
title: "toggle touch 1",
bottom: 0,
right: 0
});
var isTouch = true;
var isVis = true;
btn.addEventListener("click", function(e) {
isVis = !isVis;
if (isVis) {
childView.opacity = 1;
} else {
childView.opacity = 0;
}
})
btn2.addEventListener("click", function(e) {
isTouch = !isTouch;
childView.touchEnabled = isTouch
btn2.title = isTouch ? "toggle touch 1" : "toggle touch 0";
})
childView.addEventListener("touchstart", onTouch);
childView.addEventListener("touchmove", onTouch);
childView.addEventListener("touchend", onTouch);
childView.addEventListener("touchcancel", onTouch);
childView.addEventListener("click", onTouch);
childView.addEventListener("dblclick", onTouch);
childView.addEventListener("doubletap", onTouch);
childView.addEventListener("longpress", onTouch);
childView.addEventListener("pinch", onTouch);
childView.addEventListener("swipe", onTouch);
window.add(btn);
window.add(btn2);
window.add(childView);
window.open();
Test:
- click view -> touch output
- toggle opacity
- click view -> no touch output
- toggle opacity
- click view -> touch output
- toggle touch
- click view -> no touch output
- toggle touch
- click view -> touch output
- toggle opacity
- toggle touch
- click view -> no touch output
- toggle touch (still invisible)
- click view -> no touch output
- toggle opacity
- click view -> touch output
| Fails | |
|---|---|
| :no_entry_sign: | Test reports missing for MacOS. This indicates that a build failed or the test app crashed |
| :no_entry_sign: |
:microscope: There are library changes, but no changes to the unit tests. That's OK as long as you're refactoring existing code, but will require an admin to merge this PR. Please see README.md#unit-tests for docs on unit testing. |
| Warnings | |
|---|---|
| :warning: |
Commit 889c8ae709bdba019e0f84b5dc5ea1abed72381e has a message "click when invisible" giving 2 errors:
|
| :warning: | Tests have failed, see below for more information. |
| :warning: | This PR has milestone set to 10.0.0, but the version defined in package.json is 10.2.0 Please either: - Update the milestone on the PR - Update the version in package.json - Hold the PR to be merged later after a release and version bump on this branch |
| Messages | |
|---|---|
| :book: |
:rotating_light: This PR has one or more commits with warnings/errors for commit messages not matching our configuration. You may want to squash merge this PR and edit the message to match our conventions, or ask the original developer to modify their history. |
| :book: | :x: 1 tests have failed There are 1 tests failing and 900 skipped out of 17267 total tests. |
| :book: | :tada: Another contribution from our awesome community member, m1ga! Thanks again for helping us make Titanium SDK better. :thumbsup: |
Tests:
| Classname | Name | Time | Error |
|---|---|---|---|
| android.emulator.main.Titanium.Geolocation.methods | #forwardGeocoder() works via callback argument (12) | 5.029 | Error: expected false to be true
at Assertion.fail (/node_modules/should/cjs/should.js:275:13)
at Assertion.value (/node_modules/should/cjs/should.js:356:9)
at Geolocation.<anonymous> (/ti.geolocation.test.js:585:32) |
Generated by :no_entry_sign: dangerJS against 01bb023a0056e505271c91baf4e195913abd0c26
@m1ga Can you go over here and check again if everything works as expected? Maybe @drauggres can even help with a review :)
@hansemannn we have to check what we want here: https://jira-archive.titaniumsdk.com/TIMOB/TIMOB-27893 see the comment by Joshua from 2020-06-20.
The touchEnabled:false part is working fine now in 10.1.1.GA. This PR will only remove the events for a hidden object (opacity 0) to be inline with iOS. But if we still want to be able to click invisible items we should change that part in iOS.
I would go with the parity with the existing iOS-behavior here, but let's put that onto the agenda for the next sync meetup.