[comp.sys.mac.programmer] Password in TextEdit field?

kingman@tci.bell-atl.com (Matt Kingman) (02/09/90)

Does anyone have any good ideas on how to implement a password in a
TextEdit field?  So far, I've thought of this...

Manage 2 TextEdit records, one that the user can see and one that the
user can't.  Anything that the user types is placed into the unseen
one and an apple or diamond character is placed into the seen one.
Am I on the right track or off in the woods?  How would I handle
editing?  (ie. double clicks, cmd-c, cmd-v, etc...)  What considerations
must be made if this were done in a modal dialog?  (ie. would I need
a custom filterProc?)

Any help would be appreciated.  Thanks,

/Matt 
-- 
Matt Kingman - Systems Engineer		kingman@tci.bell-atl.com
Technology Concepts Inc.		...!uunet!tci!kingman
Sudbury, MA. 01776			(508)443-7311
  TCI is not responsible for my opinions, nor I for theirs...

lefty@twg.com (David N. Schlesinger) (02/11/90)

In article <669@tci.bell-atl.com> kingman@tci.bell-atl.com (Matt Kingman) 
writes:
> Does anyone have any good ideas on how to implement a password in a
> TextEdit field?

Since your TextEdit field is likely to be in a dialog box, let me suggest 
the following.  Use a filterProc to ModalDialog which will trap keyDown 
events, store the character the user typed into a global buffer and 
replace the character in the EventRecord with (for instance) an "apple" or 
a "diamond".  Make delete wipe out the entire text entered (since the user 
can't see what he's entered anyway).  Copy and paste can also be handled 
in the filterProc, if you want.

Hope this helps.

Lefty

===========================================================================
          David N. Schlesinger   || "There's a word for it: words don't
          The Wollongong Group   ||  mean a thing.  There's a name for it;
Internet: Lefty@twg.com          ||  names make all the difference in the
POTS:     415/962-7219           ||  world..." -- David Byrne
===========================================================================

zben@umd5.umd.edu (Ben Cranston) (02/13/90)

In article <669@tci.bell-atl.com> kingman@tci.bell-atl.com
(Matt Kingman) writes:

> Does anyone have any good ideas on how to implement a password in a
> TextEdit field?

I did see a really {cute|elegant|klugy} approach to this in a hypercard FTP
stack that needed to ask for a password.  There was a font installed in the
stack (could be installed in your program) that had but one character in it,
the diamond used to indicate a typed character.  I assume ASCII code zero
mapped directly to the diamond and all others mapped to the standard
"default character" (last character in the font: the diamond! :-).

-- 
Sig     DS.L    ('ZBen')       ; Ben Cranston <zben@Trantor.UMD.EDU>
* Network Infrastructures Group, Computer Science Center
* University of Maryland at College Park
* of Ulm