Created
September 17, 2010 15:08
-
-
Save anonymous/584359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Titanium.UI.currentWindow; | |
// make a transparent view that obscures another view (sits on top) | |
// but turn off touches against the view so that it won't explicitly | |
// handle any interaction events against it. this means that the | |
// other view in the hiearchry should instead receive the touch event | |
// which is view2. | |
var view1 = Ti.UI.createView({ | |
width:200, | |
height:200, | |
top:100, | |
touchEnabled:true | |
}); | |
var view2 = Ti.UI.createView({ | |
width:200, | |
height:200, | |
top:100, | |
borderRadius:10, | |
backgroundColor:'purple' | |
}); | |
var label = Ti.UI.createLabel({ | |
text:'Click on me', | |
color:'white', | |
font:{fontSize:15,fontWeight:'bold'}, | |
width:'auto', | |
height:'auto' | |
}); | |
view2.add(label); | |
win.add(view2); | |
win.add(view1); | |
var l = Ti.UI.createLabel({ | |
text:'click on box', | |
width:300, | |
height:'auto', | |
top:10, | |
touchEnabled:false, | |
font:{fontSize:13} | |
}); | |
win.add(l); | |
var l2 = Ti.UI.createLabel({ | |
text:'click on label', | |
width:300, | |
height:'auto', | |
top:25, | |
touchEnabled:false, | |
font:{fontSize:13} | |
}); | |
win.add(l2); | |
var l3 = Ti.UI.createLabel({ | |
text:'', | |
width:300, | |
height:'auto', | |
top:40, | |
touchEnabled:false, | |
font:{fontSize:13} | |
}); | |
win.add(l3); | |
view2.addEventListener('click',function(e) | |
{ | |
Ti.API.info('view2 event firing: '+e.source); | |
l.text = "You were able to click on the box. Good!"; | |
setTimeout(function() | |
{ | |
Ti.API.info('view2 event firing in timeout'); | |
l.text = "click on box"; | |
},1000); | |
}); | |
view1.addEventListener('click',function(e) | |
{ | |
Ti.API.info('view1 event firing: '+e.source); | |
l.text = "You clicked on the overlay!"; | |
setTimeout(function() | |
{ | |
Ti.API.info('view1 event firing in timeout'); | |
l.text = ""; | |
},1000); | |
}); | |
label.addEventListener('click',function(e) | |
{ | |
Ti.API.info('label event firing: '+e.source); | |
l2.text = "You were able to click on the label. Good!"; | |
setTimeout(function() | |
{ | |
Ti.API.info('label event firing in timeout'); | |
l2.text = "click on label"; | |
},1000); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment