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

Re: [MacPerl] Hiding dialog box input?



>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?

There is a bug in the script I put up yesterday which will make you hate me
forever if you use it unmodified.

The bug is this. If you click in the edit box the whole function is
reversed. The password is revealed and nothing is returned to the program.
Also if you 'select and cut' in the usual Mac fashion, only the bullets are
cut, not the underlying text.

This version below prevents these things happening. Sorry I spoke too soon.
I _think_ it is secure now -- I have not managed to break it yet.

Alan Fry

======================================================================

#!perl

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

$bnd = new Rect(10, 50, 200, 126);
$dlg = new MacDialog $bnd, 'Password', 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);
$dlg->sethook( "click", \&get_click );

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

sub text {
    $txt = $dlg->item_text(1);
    $len = length $txt;
    $dlg->item_text(2, chr(165) x $len );
}

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

sub get_click {
    my ($me, $pt) = @_;
    $it = FindDialogItem($dlg->window, $pt);
    if ($it == 2) { &return }
}

======================================================================



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