Skip to content

Instantly share code, notes, and snippets.

Created September 17, 2010 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/584359 to your computer and use it in GitHub Desktop.
Save anonymous/584359 to your computer and use it in GitHub Desktop.
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