[comp.sys.mac.programmer] I hate it when Apple does this . . .

mcdonald@fornax.UUCP (Ken Mcdonald) (03/11/90)

In Inside Mac, Vol I, the chapter on the dialog manager, it is stated
the the dialog item list (in memory) for a modal dialog contains handles
to the text associated with it's editText items--then gives no way to 
get a copy of these handles!  Anyone know how to do this?  (I don't 
want to use GetIText, as I don't want to extract the text, I want the
actual handle to the text.)

Thanks,
Ken McDonald
mcdonald@cs.sfu.ca

dierks@ndcvb.cc.nd.edu (Timothy Dierks) (03/12/90)

From article <420@fornax.UUCP>, by mcdonald@fornax.UUCP (Ken Mcdonald):
> In Inside Mac, Vol I, the chapter on the dialog manager, it is stated
> the the dialog item list (in memory) for a modal dialog contains handles
> to the text associated with it's editText items--then gives no way to 
> get a copy of these handles!  Anyone know how to do this?  (I don't 
> want to use GetIText, as I don't want to extract the text, I want the
> actual handle to the text.)

Inside Mac, page I-405, says that the handle returned by GetDItem for an
editText item is a handle to the current text.  If you just want to work with
the current item, there is a textH member in a dialog record that is a
handle to it.

Tim Dierks
go Irish

mcdonald@fornax.UUCP (Ken Mcdonald) (03/12/90)

In article <88@ndcvb.cc.nd.edu>, dierks@ndcvb.cc.nd.edu (Timothy Dierks) writes:
> 
> Inside Mac, page I-405, says that the handle returned by GetDItem for an
> editText item is a handle to the current text.  If you just want to work with
> the current item, there is a textH member in a dialog record that is a
> handle to it.
> 
> Tim Dierks
> go Irish

My IM doesn't say this.  (Different editions, I guess.)  More particularly,
it specifically states that to extract or set the text in a statText or
editText item, one should pass the handle produced by GetDItem to GetIText
or SetIText.  This is what made me think that the handle returned is not
a simple handle to a string--if it were, why the need for SetIText/GetI
Text?

My original comment still stands...I hate it when Apple does this! :-)

Ken McDonald
mcdonald@cs.sfu.ca

chewy@apple.com (Paul Snively) (03/13/90)

In article <422@fornax.UUCP> mcdonald@fornax.UUCP (Ken Mcdonald) writes:
> In article <88@ndcvb.cc.nd.edu>, dierks@ndcvb.cc.nd.edu (Timothy Dierks) 
writes:
> > 
> > Inside Mac, page I-405, says that the handle returned by GetDItem for 
an
> > editText item is a handle to the current text.  If you just want to 
work with
> > the current item, there is a textH member in a dialog record that is a
> > handle to it.
> > 
> > Tim Dierks
> > go Irish
> 
> My IM doesn't say this.  (Different editions, I guess.)  More 
particularly,
> it specifically states that to extract or set the text in a statText or
> editText item, one should pass the handle produced by GetDItem to 
GetIText
> or SetIText.  This is what made me think that the handle returned is not
> a simple handle to a string--if it were, why the need for SetIText/GetI
> Text?
> 
> My original comment still stands...I hate it when Apple does this! :-)
> 
> Ken McDonald
> mcdonald@cs.sfu.ca

I hate it when we do that, too. :-)

As I recall, the reason that we have Set/GetIText is that there's some 
additional information about text being maintained by the Dialog Manager, 
such that you can't simply munge the text handle and expect the right 
things to happen.  It's kind of unfortunate, and as I don't happen to have 
ROM sources in front of me ;-) I can't tell you exactly what goes on in 
there.

Why don't you tell us what it is that you wish to accomplish, and perhaps 
someone here can tell you how to go about it?  You may be quite safe using 
the text handle that GetDItem returns, for example, as long as you don't 
change anything about it.  One possible example of such a use would be 
saving some text from a preferences dialog as a STR resource in a 
preferences file.

__________________________________________________________________________
                                Paul Snively
                      Macintosh Developer Technical Support
                             Apple Computer, Inc.

1st Choice: Paul_Snively.DTS@qm.gateway.apple.com
2nd Choice: CHEWBACCA@applelink.apple.com
Last Choice: chewy@apple.com

Just because I work for Apple Computer, Inc. doesn't mean that I believe 
what they believe, or vice-versa.
__________________________________________________________________________

amanda@mermaid.intercon.com (Amanda Walker) (03/13/90)

In article <7133@goofy.Apple.COM>, chewy@apple.com (Paul Snively) writes:
> As I recall, the reason that we have Set/GetIText is that there's some 
> additional information about text being maintained by the Dialog Manager, 
> such that you can't simply munge the text handle and expect the right 
> things to happen.

I've never had any problem doing all sorts of violence to dialogs behind
the DM's back (hmm.. no pun intended there :-)).  SetIText and GetIText
make it real easy to move things between text fields (of either flavor)
and Str225's.  However, GetDItem and SetDItem seem to handle all of the
actual bookkeeping and keeping TextEdit informed as to what's going on.

I use GetDItem and SetDItem to avoid the 256-character-per-field limitation
you get with GetIText & SetIText.

--
Amanda Walker
InterCon Systems Corporation

"Many of the truths we cling to depend greatly upon our own point of view."
	--Obi-Wan Kenobi in "Return of the Jedi"

brecher@well.sf.ca.us (Steve Brecher) (03/14/90)

In article <422@fornax.UUCP> mcdonald@fornax.UUCP (Ken Mcdonald) writes:

> [IM] specifically states that to extract or set the text in a statText
> or editText item, one should pass the handle produced by GetDItem to
> GetIText or SetIText.  This is what made me think that the handle
> returned is not a simple handle to a string--if it were, why the need
> for SetIText/GetI Text?

It is not a handle to a (Pascal) string; it is a handle to raw text,
with no preceding length byte.  The length of the text is given by
GetHandleSize.  What GetIText does is to make a Pascal string from
the text; SetIText does the converse.
-- 

brecher@well.sf.ca.us (Steve Brecher)