dynamic content in a webos command menu
- August 25th, 2009
- Posted in Uncategorized
- Write comment
As i have been doing more webos app development, i thought i would just keep little snippets of things i learned as i was developing. One thing that i really wanted to do was to have a spinner in as a button in the command menu (aka the button bar at the bottom). First you need the code to setup the commandMenu. This is called in the setup method of your assistant. In this case, i have a menu with a new button on the left and 2 buttons on the right and a spinner in the last spot (aka the dynamic content).
this.cmdMenuModel = { items: [
{
items: [{label: $L('New'), icon: 'new', command: 'new'}]
},
{},
{
items: [
{label: $L('undo'), icon: 'refresh', command: 'undo'},
{label: $L('search'), icon: 'search', command: 'search'},
{example: 'A', template: 'common/spinner'}]
}]
};
this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);
this.controller.setupWidget('spinner', {
spinnerSize: Mojo.Widget.spinnerSmall,
},
sceneAssistant.spinnerModel = {
spinning: true
});
this.spinnerWidget = this.controller.get('spinner');
The template for something to show up in the button bar looks like this. This makes it still look like a button but you can show your content. The main thing to notice is that the item from the command model above is passed to the template for variable expansion.
Now you should have something that looks like:
Also, you can now enable and disable the spinner with:
this.spinnerModel.spinning = false; this.controller.modelChanged(this.spinnerModel);

hi, i’m trying to use the template attribute as well but am having trouble. could you help me?
where did you put the template file, namely: “common/spinner.html”?
i’m having trouble making the template attribute find my template HTML file.
thanks!
Richard
Richard, sorry for the delayed response but could you give me an idea of what you are trying to change with the template attribute?
Hi, I’m trying to do exactly what your example show. but with “#{example}” in the template file the example don’t work. If I replace the template content with “” the spinner get displayed but not in the right place. Could you please share the template you used to get the spinner displayed correctly?
Thanks in adavance.
Regards,
Olivier
Hi Olivier,
The entire template is just that #{example}, if you can give me a snippet to look at i could try to figure out what it is not showing up in the proper location.