Re: Dialog Director - Counting Characters
Re: Dialog Director - Counting Characters
- Subject: Re: Dialog Director - Counting Characters
- From: Gary Lists <email@hidden>
- Date: Tue, 15 Jul 2003 18:28:51 -0400
On or about 7/15/03 12:31 PM, Bill Steele wrote:
>
> Do any of you have an example of using Dialog Director to count the
>
> characters _as they are entered_ in a dialog text field and increment a set
>
> of digits?
>
>
>
> (The idea is to display the incrementing character count as the characters
>
> are typed.)
>
>
>
> TIA
>
> --
>
> Gary
>
>
You might be able to do this with one of the keystroke-trapping
>
OSAXen, but Dialog Director doesn't know what you've typed until you
>
finish and hit OK.
Okay, I was discouraged by this earlier report, but -- head down and eyes
closed -- I trudged forward and it wasn't as difficult as I had thought.
The 'dd interact with user' command (which we were already using in our
two-field, two-button dialog) was all that was needed.
I suppose that I thought going in that I would need some other "magic" to
get each key pressed. Not the case. The 'interact' event is just ongoing
and not a problem to deal with.
If you have the DD osax installed and you want to see how easy this turned
out to be, then here is an ugly but functional dialog sample that shows the
character counting.
-- [wrapping will probably be gnarly here...watch it]
set theDialogStructure to {size:{320, 110}, style:standard palette,
closeable:true, name:"TestWin", default item:3, contents:{
[SOFTBREAK_OR_NOBREAK]
{class:text field, bounds:{19, 47, 199, 61}, value:"Text Field",
font:{name:"Geneva", size:10}}, [SOFTBREAK_OR_NOBREAK]
{class:text field, bounds:{19, 68, 80, 80}, value:"30",
font:{name:"Geneva", size:9}}, [SOFTBREAK_OR_NOBREAK]
{class:push button, bounds:{232, 44, 306, 64}, name:"OK"}}}
-- [and the real guts...not much to it afterall]
-- [I don't see any wrapping here...you're golden]
dd install
set fileNamerDialog to dd make dialog theDialogStructure
repeat
set userItem to dd interact with user
if userItem = -1 or userItem = 3 then
exit repeat -- close or OK button
else if userItem = 1 then -- typing in the text field
-- count characters and then update guage
set fileNameEntry to (dd get value of item 1 of fileNamerDialog)
set char_remain to (30 - (length of fileNameEntry))
if char_remain < 0 then
set char_remain to "TOO LONG"
beep
end if
dd set value of item 2 of fileNamerDialog to char_remain
else if userItem = 2 then
-- task
end if
end repeat
set fileNamerDialogValues to dd get value of every item of fileNamerDialog
dd delete fileNamerDialog
dd uninstall
Mucho gusto,
--
Gary
MacOS 9.1 / "9 is Fine"
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.