<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Firm Foundation Technology &#187; WebOS Dev</title>
	<atom:link href="http://www.firmfoundationtechnology.com/category/webos-dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.firmfoundationtechnology.com</link>
	<description>Mobile Apps for Practical Problems</description>
	<lastBuildDate>Sat, 24 Sep 2011 21:49:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WebOS SDK &#8211; Making buttons</title>
		<link>http://www.firmfoundationtechnology.com/2010/07/01/webos-sdk-making-buttons/</link>
		<comments>http://www.firmfoundationtechnology.com/2010/07/01/webos-sdk-making-buttons/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 14:23:48 +0000</pubDate>
		<dc:creator>stan</dc:creator>
				<category><![CDATA[WebOS Dev]]></category>

		<guid isPermaLink="false">http://www.firmfoundationtechnology.com/?p=53</guid>
		<description><![CDATA[From a post I made in the Palm developer forums (hope it is helpful to someone): Here is my summary of making a button (from lots of trial) In the scene HTML declare this &#60;div x-mojo-element="Button" id="RefreshBtn" class="myButton"&#62; &#60;/div&#62; Notice &#8230; <a href="http://www.firmfoundationtechnology.com/2010/07/01/webos-sdk-making-buttons/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>From a post I made in the Palm developer forums (hope it is helpful to someone):</p>
<p>Here is my summary of making a button (from lots of trial)</p>
<p>In the scene HTML declare this</p>
<pre>
&lt;div x-mojo-element="Button" id="RefreshBtn" class="myButton"&gt; &lt;/div&gt;
</pre>
<p>Notice that this is a div not an input element like traditional html. The x-mojo-element=&#8221;Button&#8221; is what what links the div to the mojo framework that does all the button drawing stuff.</p>
<p>The id is important and should be unique in the app. Good practice is to put something like &#8220;Btn&#8221; or &#8220;Button&#8221; in the name just to remind yourself when you are in your javascript what you are working with. The class declaration is only needed if you are changing the appearance some way in your own CSS.</p>
<p>Next in the scene assistant you need three things. Setup, control, and cleanup.</p>
<p><strong>Setup:</strong><br />
In the Scene Assistant setup function &#8211; usually something like FirstAssistant.prototype.setup = function () {};  there are 4 substeps</p>
<p><em>1 Attributes</em> :<br />
Technically these are all optional (if you just need a regular button) but I feel it is good practice to declare at least the button type like thus:</p>
<pre>
// a local object for button attributes
this.RefreshBtnAttributes = {
type : "Mojo.Widget.defaultButton"
};
</pre>
<p>again just to remind myself this is a regular button rather than an Mojo.Widget.activityButton  (unless you want one and then you must declare it)</p>
<p><em>2 Model</em> :</p>
<pre>
// a local object for button model
this.RefreshBtnModel = {
label : "Refresh",
buttonClass : "primary",
disabled : false
};
</pre>
<p>Again all are technically optional for the defaults, except the label needs to appear in either the attribute or the model.  Legal values for button class are &#8220;primary&#8221;, &#8220;secondary&#8221;, &#8220;affirmative&#8221;, and &#8220;negative&#8221;.</p>
<p><em>3: setup the button</em></p>
<pre>
// set up the button
this.controller.setupWidget("RefreshBtn", this.RefreshBtnAttributes,
              this.RefreshBtnModel);
</pre>
<p>Straight forward. this is where your ID links in from the HTML.</p>
<p><em>4. Bind the button</em></p>
<pre>
// bind the button to its handler
this.RefreshBtnBind = this.refreshButtonPress.bind(this);
this.controller.listen(this.controller.get("RefreshBtn"), Mojo.Event.tap,
               this.RefreshBtnBind);
</pre>
<p>refreshButtonPress will be the name of the handler to be declared. Again notice the link to the ID from the HTML.</p>
<p><strong>Control :</strong><br />
The &#8220;simplest&#8221; part &#8211; define what to do when the button is pressed (&#8220;tapped&#8221;)  like thus :</p>
<pre>
FirstAssistant.prototype.refreshButtonPress = function(event){

// do something here

};
</pre>
<p><strong>Cleanup:</strong></p>
<p>Finally make sure you clean up something like this :</p>
<pre>
FirstAssistant.prototype.cleanup = function(event) {
this.controller.stopListening("RefreshBtn", Mojo.Event.tap,
               this.RefreshBtnBind);
};
</pre>
<p>Add the stopListening counterparts to the listen binds of any other widgets you declare for the scene as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.firmfoundationtechnology.com/2010/07/01/webos-sdk-making-buttons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

