Email:   
Home
In This Issue
EasyPrint
Click here for the RSS feed's XML code. This is not a browser URL.
Playing the field (continued)

When a field is tapped, that field is selected. From that point on, until the form is closed or you select another field, any Graffiti or keyboard characters go into that field.

Looking at the Infield sample
As I mentioned, Infield began as the "Hello, world" program. I added:

  • changes to the user interface; the field itself and several push-buttons;
  • several "library" routines in the beginning;
  • handlers for the push-buttons (ctlSelectEvent);
  • keyDownEvent handler for "special effects";
  • nilEvent handler to do some post-field change processing;
  • EventLoop changed to get nilEvents;
  • change to form's frmOpenEvent to set default push-button setting and select the field.

Let's look at each of these. You can see a listing at http://www.component-net.com/pp-extras/field.html.

User interface changes
Well, obviously if we're going to use a field, we need to have one -- so I added the field itself. I defined it as a maximum of 20 characters, underlined, usable, editable, and a single line.

I also defined a group of three push-buttons. These allow the user to filter out characters, setting the field to allow any characters, forcing alphabetic characters to upper case, or only allowing numeric characters.

Included "library" routines
For convenience, I've kept everything in a single source file. As these samples are small, I find it convenient to deal with just one listing. In reality, the routines such as toupper, isnumeric, and isprintable are in a library. These routines do just what you'd expect -- at least when using English characters; they take the US-centric view of the ASCII character set -- and I apologize to our international readers.

Handling the Push-buttons
Tapping the push-buttons generate (amongst other events) a ctlSelectEvent. This indicates the particular control has been selected. I added ctlSelectEvent handlers for the push-buttons to MainFormHandleEvent. Each push-button control sets or clears the two global boolean flags, fForceUpper and fNumericOnly. The keyDownEvent handler uses these flags to force characters to upper case or filter non-numerics.

The keyDownEvent handler
This is a bit unusual -- fields normally do keyDownEvent handling on their own. I put it in to demonstrate some additional techniques. We can modify the event before the default handler gets it, as we do when fForceUpper is set. When we're forcing upper-case characters, we check the character in the keyDownEvent structure. If it's an alphabetic character, we force it to upper case, then allow the default handler to process it. If the fNumericOnly flag is set, we do similar checking for numeric characters. In this case, if the character is not a number, we return "handled" -- so the default handler won't process the event at all.

This technique isn't perfect, though. It works for characters entered by Graffiti, but if the user enters characters via the on-screen keyboard, those characters are stuffed right into the field's data -- they don't go through the keyDownEvent processing. I have neither Jot, T9, nor the GoType! keyboard, so I couldn't check if they will work with keyDownEvent processing or not.




[ Prev | Next ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

ONLINE GROUP CALENDAR - FOR UP TO 100 OF YOUR CLOSEST FRIENDS
Stay organized and in control with 24/7 access to all of your important events, projects and files --whether you're at work, at home or on the road.

You can share your calendar, projects and files so everyone in your office is up to date. Plus, search your entire group to find times when everyone is available to meet, manage company resources and much more.

Organize your entire team for as low as $9.95 per year (and yes, that's where the decimal place is supposed to be!)

Tap here to get started right away.

-- Advertisement --

SECURE YOUR SITE WITH AN IRONCLAD SSL CERTIFICATE
An IronClad SSL Certificate helps you build an impenetrable fortress around your customer's credit card information. IronClad SSL Certificates are:

  • Fully validated
  • Up to 256-bit encryption
  • Up to 10 years validity
  • Stringent authentication
  • Around-the-clock customer support

Build trust. Protect your customers. Grow your online business.

Tap here now and be IronClad with SSL tonight.

Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.