Created
May 15, 2012 22:37
-
-
Save meeech/2705664 to your computer and use it in GitHub Desktop.
Longpress example for Titanium toolbar
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 = Ti.UI.createWindow({ | |
backgroundColor: "#ccc", | |
fullscreen: true, | |
modal: true | |
}); | |
//Create the button. We use backgroundImage so that we get | |
//the standard effect where the button get grey when tapped | |
var button = Titanium.UI.createButton({ | |
width: 40, | |
height: 40, | |
backgroundImage:'images/plus.png' | |
}); | |
//Create the container - we apply the event listeners to this view. | |
//In this example, its just the size of the button itself. | |
var buttonContainer = Ti.UI.createView({ | |
width: 40, | |
height: 40 | |
}); | |
buttonContainer.addEventListener('longpress', function(e) { | |
alert('Longpress!'); | |
}); | |
//We use Singletap instead of click - otherwise, the click will fire when you remove your finger | |
//under normal circumstances (not when using an alert, but during normal flow it will) | |
buttonContainer.addEventListener('singletap', function(e) { | |
alert('Singletap'); | |
}); | |
buttonContainer.add(button); | |
win.setToolbar([buttonContainer]); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment