Search PalmPower's 487 Palm-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Programming controls in PalmOS (continued)

Well, that depends on the type of control. For a button, we get a ctlSelectEvent event when the user taps and releases the button. We saw in the "hello world" application how a button works: it's drawn when the form is drawn, and when the user presses it, the ctlSelectEvent message triggered the application to do some function. Listing B (at http://www.component-net.com/pp-extras/control2.html) shows that section of the form event handler. For the full program, see the May 1998 issue.

Repeating buttons use a similar event, the ctlRepeatEvent. One thing to remember: the ctlRepeatEvent handler needs to return "not handled" so the event will be passed on to the handler within the OS. If you don't, the button won't repeat. Normally, the section in the form handler which deals with the control's selection returns "handled", since it did do something with that event.

The controls generate several other events; we can act on these events if we want to do something special. The ctlEnterEvent indicates that the user has tapped on a control; at this point the pen is still down. The ctlExitEvent indicates the pen was dragged outside of the control. If it's dragged back into the control, there will be another ctlEnterEvent. These allow activity to occur when a user presses on a control, rather than upon the release.

Sometimes I prefer to let the OS track the control's settings and then get the value when I close a form. I do this in my application's preferences screen. The user can select his or her preferences, and rather than acting on each ctlSelectEvent, I wait for the form to exit, and then query the OS for the current state of each control. Naturally, this doesn't work for buttons. They're only "set" as long as the user is pressing on them. But it works fine for pushbuttons and checkboxes. It has the added advantage of delaying any real changes until the form exits, so I can implement a Cancel button on the form. This way, when the user presses the Ok button, the exiting-form routine gets the value of each control and remembers whatever information it should. If the user presses Cancel the form just exits without updating getting any control settings or changing any of the application's information.

Next month
We'll keep digging into controls as time goes on, and we'll get into other UI objects, especially fields; they tend to not work as you'd expect. But I think next month we'll start playing with some more code. My 3-year-old son's been clamoring to play with my PalmPilot, so why don't we write a simple game? Let's seeÉ some bitmaps, some pen-tap recognitionÉ

Until then, keep all your bits where they belong!

Alan Weiner fiddles with bits and dabbles with data. His email address is alan@ajw.com.


« Previous  ·  1  ·  2  ·  3
Other articles you might like
Home > Phones and PDAs > Palm and Treo > Programming (24 articles)
   How PDA software is born
   Program with Simplicity
   Kinectivity 2.0 brings enterprise application developers new tools
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Other PalmPower Articles
Palm gets up to date with new Tungsten family of handhelds
Create handwritten email with riteMail
Presenter-to-Go puts PowerPoint presentations on your Palm OS handheld
Looking for the cutting edge
Gain remote access to databases and PLCs
PalmSource Open House showcases what's new in the Palm community
Analysis: handheld market share
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
DominoPower: Application development, William Shatner, and the origin of the universe
OutlookPower: More about disappearing text
-- Advertisement --

BLOGGING AND PODCASTING WITH ONE EASY-TO-USE TOOL
Now you can publish your thoughts, opinions, and comments in your own blog or podcast.<p />

  • Supports multiple authors and multiple blogs or podcasts.
  • Generate and publish RSS feeds for iTunes and other directories.
  • Post photos, images or animations.
  • Get feedback and have conversations with visitors to your site. <p />

Personalize your blog or podcast with your own unique domain name -- or integrate it with your existing site by setting it up as a subdomain.

Tap here and get blogging or podcasting within minutes.

-- Advertisement --

Sent Items Organizer
When you need to file your sent email into their proper folders based on keywords or who it's to. It's also perfect for shared mailboxes.

It also adds a "Send And File" toolbar button while you're composing (similar to the way Lotus Notes used to work) for quick and easy filing.

Find out more!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login