[comp.sys.mac.programmer] Insertion point in cdev.

resnick@cogsci.uiuc.edu (Pete Resnick) (04/15/91)

I have encountered a small problem in my cdev. I want to turn an
EditText box into a StatText box on the fly as part of my initDev
routine; under certain conditions, I want one of my text boxes not
to be editable. So I do the following (in C):

  GetDItem(CPDialog, ITEM_NUMBER + numItems, &tempType, &tempHandle, &tempRect);
  SetDItem(CPDialog, ITEM_NUMBER + numItems, statText, tempHandle, &tempRect);

Well, that works fine, except for the fact that I still have the cute
little insertion point flashing in my now apparently static text field.
How do I get rid of it?

pr
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD

lim@iris.ucdavis.edu (Lloyd Lim) (04/16/91)

In article <1991Apr15.043144.13345@ux1.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
>I have encountered a small problem in my cdev. I want to turn an
>EditText box into a StatText box on the fly as part of my initDev
>routine; under certain conditions, I want one of my text boxes not
>to be editable. So I do the following (in C):
>
>  GetDItem(CPDialog, ITEM_NUMBER + numItems, &tempType, &tempHandle, &tempRect);
>  SetDItem(CPDialog, ITEM_NUMBER + numItems, statText, tempHandle, &tempRect);
>
>Well, that works fine, except for the fact that I still have the cute
>little insertion point flashing in my now apparently static text field.
>How do I get rid of it?

These comments apply to any dialog.  A direct method is to fiddle with the
editField in the DialogRecord.

A better, more compatible way (IMHO), is to call HideDItem and ShowDItem.
If the item you're hiding is the current editText item, HideDItem either
moves the insertion point to another editText item or gets rid of it if
there aren't any others. 

Yes, I confess.  I know this because I've abused the Dialog Manager in the
past with some dynamic dialogs - not because I know IM by heart.  :-)

+++
Lloyd Lim     Internet: lim@iris.eecs.ucdavis.edu
              America Online: LimUnltd
              Compuserve: 72647,660
              US Mail: 215 Lysle Leach Hall, U.C. Davis, Davis, CA 95616