[TIMOB-10361] TiAPI: TouchPassThrough for views
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Low |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | Release 3.0.0 |
| Fix Version/s | n/a |
| Components | Android, iOS |
| Labels | api, touch, transparent, view |
| Reporter | Martin Guillon |
| Assignee | Pedro Enrique |
| Created | 2012-08-08T10:19:13.000+0000 |
| Updated | 2015-04-13T20:09:45.000+0000 |
Description
It would be nice to be able to set touchPassThrough for a view: When clicking on a transparent part of the view, the touch is sent to the parent.
pull request: https://github.com/appcelerator/titanium_mobile/pull/2696
test case
var win = Ti.UI.createWindow({ fullscreen: true, backgroundColor: 'white'}); var button = Titanium.UI.createButton({ title:'you can touch me!', width:200, height:40, top:20 }); button.addEventListener('click', function() { alert("you clicked me when i am actually under another view!"); }); var button2 = Titanium.UI.createButton({ title:'you cant touch me!', width:200, height:40, bottom:20 }); button2.addEventListener('click', function() { alert("that shouldn t happen!"); }); win.add(button); win.add(button2); var view = Ti.UI.createView({ top:0, touchPassThrough:true, height:'50%' }); var view2 = Ti.UI.createView({ bottom:0, height:'50%' }); win.add(view); win.add(view2); win.open();It s now also working on android. See the pull request https://github.com/appcelerator/titanium_mobile/pull/2696
I can vouch for the validity of these use cases, and others. I've encountered these in apps I've built for Appcelerator, and having this property would greatly reduce the complexity of my code in some cases and make other cases, formerly impossible, possible.