About Keyboard Support in Pickers
In most Newton applications, when the user selects an item in a picker, the picker'sPickActionScript
is called, and when the user taps outside of the picker, the picker'sPickCancelledScript
is called. When you have key commands defined in a picker view, this changes.In the Newton 2.1 OS, when the user selects an item in a picker, the system first determines if the item has a key-command associated with it. If so, the method associated with that key-command (its
keyMessage
) is called instead of thePickActionScript
.You can override this by adding the
alwaysCallPickActionScript
flag to your picker. When this flag is on (set totrue
), the system software always calls thePickActionScript
, regardless of whether or not there's a key-command for the item. If thealwaysCallPickActionScript
flag is off (set tonil
), the system software calls the key-command method for the item if there is one, and calls thePickActionScript
method for the item if there is not a key-command associated with it.
- WARNING
- You must always set the
alwaysCallPickActionScript
flag totrue
in theprotoLabelPicker
andprotoLabelInputLine
protos; otherwise, these protos do not function properly. Note that you can still call the key-command method for an item in one of these pickers, as shown in "Calling a Key-Command Method From a Picker Script".![]()
Calling a Key-Command Method From a Picker Script
As described in "About Keyboard Support in Pickers", your key-command methods can be automatically called when a user selects an item in a picker. This happens when thealwaysCallPickActionScript
flag is set to nil in a picker.There are two picker protos that do not work properly when the
alwaysCallPickActionScript
flag is set tonil
:protoLabelPicker
andprotoLabelInputLine
. You must set thealwaysCallPickActionScript
flag totrue
in these protos.If you want to call a key-command method when the user selects an item in a
protoLabelInputLine
orprotoLabelPicker
, you need to call the key-command method from thePickActionScript
for that proto.Listing 4-1 shows an example of calling a key-command method from a picker. In this sample code, the method is called from the
labelActionScript
, which is called by the proto'spickActionScript
.Listing 4-1 Calling a key-command method from a picker
labelActionScript: func(cmd)
begin local item := labelCommands[cmd]; if item.keyMessage then SendKeyMessage( self, item.keyMessage ); else // do normal item processing here end;
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help