Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!chablis!shane From: shane@chablis.cc.umich.edu (Shane Looker) Newsgroups: comp.sys.mac.programmer Subject: Re: Editable TextItems in Dialogs - Help! Message-ID: <887@mailrus.cc.umich.edu> Date: 25 Jan 89 16:11:26 GMT References: <3543@ucdavis.ucdavis.edu> Sender: usenet@mailrus.cc.umich.edu Reply-To: shane@chablis.cc.umich.edu (Shane Looker) Organization: University of Michigan Computing Center, Ann Arbor Lines: 28 In article <3543@ucdavis.ucdavis.edu> jedeline@deneb.ucdavis.edu (Jim Deline) writes: > >I would like to be able to parse a string as it is being typed >into an editable textitem field of a dialog, and have all numbers >typed appear subscripted relative to the rest of the string. > >For instance, if I were to type the string 'C6H6' I would like >the number six to be subscripted in all occurrences - as in >a molecular formula. I would like to be able to do this 'on >the fly' - ie. as the string is being typed. > >Does anyone know if this can be done? > >Jim Deline An interesting idea. I don't think you can do it with the normal EditText item, since it uses TextEdit. Probably your best bet is to create a UserItem which is modified (the text in it) based on what field you are in, and what key is hit. The way to do that is to create a filter proc which interecpts keydown events, and modifies a global variable. Then return a hit in the UserItem from the filter proc, and re-draw the UserItem with the current string. You could use just a 1 character buffer to decide what to do with the key which was just hit. If you do this, remember to accept and as button 1, and cmd-. as button 2. (Standard Mac interface.) Shane Looker | Looker@um.cc.umich.edu | shane@chablis.cc.umich.edu