Let's say I have a form w/ several fields and a button.  When the 
button is pressed, I'd like whichever field currently has the focus to have 
it's text set to "howdy".  This is what I'm doing... and instead of 
"howdy", the selected field winds up with 5 spaces added to it.  Could 
somebody tell me what I'm doing wrong?


static Boolean MainFormHandleEvent(EventPtr eventP)
{
        ...
        switch (eventP->eType)  {
                case ctlSelectEvent:  // A control button was pressed and released.
                        switch (eventP->data.ctlEnter.controlID)  {
                                case ProgramMainTestButton:     // the single button 
on the form
                                        if ((fldP = GetFocusObjectPtr()) != NULL)  {
                                                textH = MemHandleNew(10);
                                                if (textH)  {
                                                        textP = MemHandleLock(textH);
                                                        StrPrintF(textP, "Howdy");
                                                        MemHandleUnlock(textH);
                                                        if (FldGetTextPtr(fldP))
                                                                FldDelete(fldP, 0, 
FldGetTextLength(fldP));
                                                        FldSetTextHandle(fldP, textH);
                                                }
                                        }
                                        break;
                        }
                break;
        }
}

Reply via email to