Skip to content

Instantly share code, notes, and snippets.

@freekrai
Last active August 29, 2015 14:28
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 freekrai/60249af99f5710057d6d to your computer and use it in GitHub Desktop.
Save freekrai/60249af99f5710057d6d to your computer and use it in GitHub Desktop.
test.js
/**
* Welcome to Pebble.js!
*
* This is where you write your app.
*/
var UI = require('ui');
var Vector2 = require('vector2');
var main = new UI.Card({
title: 'Pebble.js',
icon: 'images/menu_icon.png',
subtitle: 'Hello World!',
body: 'Press any button.'
});
main.show();
main.on('click', 'up', function(e) {
var menu = new UI.Menu({
sections: [{
items: [{
title: 'Pebble.js',
icon: 'images/menu_icon.png',
subtitle: 'Can do Menus'
}, {
title: 'Second Item',
subtitle: 'Subtitle Text'
}]
}]
});
menu.on('select', function(e) {
console.log('Selected item #' + e.itemIndex + ' of section #' + e.sectionIndex);
console.log('The item is titled "' + e.item.title + '"');
});
menu.show();
});
main.on('click', 'select', function(e) {
var wind = new UI.Window();
var textfield = new UI.Text({
position: new Vector2(0, 50),
size: new Vector2(144, 30),
font: 'gothic-24-bold',
text: 'Text Anywhere!',
textAlign: 'center'
});
wind.add(textfield);
wind.show();
});
main.on('click', 'down', function(e) {
var card = new UI.Card();
card.title('A Card');
card.subtitle('Is a Window');
card.body('The simplest window type in Pebble.js.');
card.show();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment