use api ...
Hi,
maybe its a stupid question, i just start to use titanium.
I have a problem. I don't understaind how use api.
I have a file index.html with :
<html><head><script>var menu = Titanium.UI.createMenu();
var file = menu.addSubMenu("File");
var help = menu.addSubMenu("Help");
file.addItem("Open", function () { alert('Do open');});
file.addSeparator();
file.addItem("Exit", function () { Titanium.App.exit(); });
help.addItem("About", function () { alert('Show about box here'); });
Titanium.UI.setMenu(menu);
</script></head><body style="background-color:#1c1c1c;margin:0">
<div style="border-top:1px solid #404040">
<div style="color:#fff;;padding:10px">TEST !!!
<br /></div></div></body></html>
but the api don't work …
why ?
thanks !
6 Answers
-
Well, after some testing i came up with an working js snippet.
<script> var menu = Titanium.UI.createMenu(); // Menu var var testMenuItem = menu.addItem("Test"); // add "Test" item to menu var testSub = Titanium.UI.createMenu(); // Test item submenu testSub.addItem("Test1",function () { alert('Test1');}); testSub.addItem("Test2",function () { alert('Test2');}); testSub.addSeparatorItem(); testSub.addItem("Test3",function () { alert('Test3');}); testSub.addItem("Test4",function () { alert('Test4');}); // Add menu items testMenuItem.setSubmenu(testSub); // Set as submenu Titanium.UI.setMenu(menu); // Set the whole menu </script>
Hope this helps.
-
If you are starting out I would recommend setting up the KitchenSink app and learning from there:
http://github.com/appcelerator/KitchenSink
Also, check out the webinars.
-
You need to put your javascript in between script tags.
-
thanks for your answer.
With script tag, the scritp don't work to …
but i go to see the kitchensink link ;-) -
The kitcheninks is for mobile developpement.
I search for desktop developpement :-( -
up