I have been searching for an elegant solution to allow negative number input 
into fields and tables. I initially simply set these fields to text fields. 
That was an acceptable workaround until the availability of keyboard based 
devices such as the Treo. With this workaround, the numeric input shift is not 
automatically selected when the user selects one of these fields (or table 
cells). I finally found a reasonable solution and I wanted to document it here 
in case there were others that were still struggling with the problem.

First, set the field attributes to numeric. For tables this is done using 
FldGetAttributes & FldSetAttributes in the load procedurre that you specified 
with TblSetLoadDataProcedure (this is where I also set the editable, underlined 
and autoShift attributes).

Next, provide a keyDownEvent handler that looks for a minus sign and simply 
pastes it into the field using FldInsert. I also check that the field in focus 
(FrmGetFocus) is the desired field, and that FldGetInsPtPos returns 0. For 
tables, the object in focus is the table, so I further check the row and/or 
column (TblGetSelection & TblGetCurrentField).

I actually wrapped all of this up into a function (called from the keyDownEvent 
handler) that checks a range of fields and/or table columns.

Laurie
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to