Archive for August, 2009

dynamic content in a webos command menu

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.

#{example}

Now you should have something that looks like:

Spinner Command Menu

Also, you can now enable and disable the spinner with:

	this.spinnerModel.spinning = false;
	this.controller.modelChanged(this.spinnerModel);

inertia

I have been thinking a lot about what it takes to start a company or even start anything in the world. Starting a website, a blog, a project or even something as simple as an exercise schedule. For all of these things it takes something very simple, it just takes the first step towards doing it. The larger the task the harder it is to take that first step, but i have also realized that once you take the first step, the second, third, etc become exponentially easier. I don’t think this is something that just I have discovered. If you read any self help book or talk to any motivational speaker they tell you this and yet its hard. Its hard to internalize it, its hard to step out. Some of it is fear, some of it is just laziness. Somehow, a single step just seemed subtly simple. I hope that all of you have the ability to take your first step….

Return top