Thomas Ward wrote:

Hi,

I have a field whose contents need to be all capital letters. A long time ago, 
I wrote this code to do it:

case keyDownEvent:
  if (FrmGetFocus(frm) == FrmGetObjectIndex(frm, capsfield))
     event->data.keyDown.chr = upper_char(event->data.keyDown.chr);
  break;

I then return false from the handler, and this code has worked correctly for 
years. I just tried it, and it still works in the Emulator, through OS 4. But in 
the simulator, it no longer works. Stepping through the code, if I enter a 
lowercase 'a', I see the call to upper_char changes the value in 
event->data.keyDown.chr from 97 to 65, which is correct for a captial 'A'. 
However, it's still a lowercase 'a' that is actually getting inserted into the 
text field. This happens in the Treo 650, T3, and Sony OS 5 simulators, and an OS 
5 device.

Anybody know what's going on here? Why does this approach no longer work? What 
do I need to change to make it work in OS 5? Thanks.
The first place I would look is to determine WHERE in my event loop that event is being handled. Inserting a character into a field would likely be handled by the system, no? So if you call SysHandleEvent() right after EvtGetEvent() in your event handler then the insert has already happened before you get access to that keyDown. I've found that, depending on what you need to achieve, a select few events might need to be handled right after EvtGetEvent, to keep the system from trumping your wishes, with the bulk of your handling happening later on (usually after SysHandle.. and MenuHandle..., etc.). Just a thought. Bob

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

Reply via email to