[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Hiding dialog box input?



Jeremy Bierbach <jerb@gene.com> wrote on 26 Feb 1998 16:37:42 -0700:

>One problem remains, though: for this runtime to be ready for company-wide
>use, I have to make the input invisible or bulleted-out in my MacPerl::Ask
>dialog requesting the user's password. Does anyone have any suggestions about
>how I could accomplish this?

This will do it in a somewhat roundabout fashion:

#!perl

use Mac::Events;
use Mac::Windows;
use Mac::Dialogs;

$bnd = new Rect(10, 50, 200, 126);
$dlg = new MacDialog $bnd, 'Hidden Entry', 1, 0, 1, (
    [ kEditTextDialogItem, new Rect(10, 15, 180, 30), '' ],
    [ kEditTextDialogItem, new Rect(10, 15, 180, 30), '' ],
    [ kButtonDialogItem,   new Rect(120,45, 180, 65), 'Return']
);

SetDialogDefaultItem($dlg->window, 3);
HideDialogItem($dlg->window, 1);
SelectDialogItemText($dlg->window, 1);
$dlg->item_hit(3 => \&return);

while ($dlg->window) {
    if (length $dlg->item_text(1) ne $len) { text() }
    WaitNextEvent(1);
}

sub text {
    $txt = $dlg->item_text(1);
    $len = length $txt;
    $dlg->item_text(2, '*' x $len ); # that's 'option->*'
}

sub return {
    print $txt, "\n";
    dispose $dlg
}

Text is entered into a hidden dialog box and copied into a visible box. The
hidden box is actually in the same position as the visible one. Updating
the text via the subroutine 'text' avoids 'jitter'.

I would be grateful for some feedback; if it serves the purpose it might be
worth turning into a simple module. Views on this would be welcome.

Alan Fry



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch