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

[MacPerl] errors in Windows.pm?



I had trouble with calling 'new MacWindow' when I have a WIND resource that
I'm trying to use. I think the syntax (to get WIND #2000, assuming I've got
that in an open resource file) is:

$myWindow = new MacWindow 2000 [, BEHIND];

I can't get this form to work. I can, however, create a new window using
the alternate form of:

new MacWindow BOUNDS, TITLE, VISIBLE, PROC, GOAWAY [, REFCON [, BEHIND]]

I'm not sure I'm right here, but is the problem with line 397 of "Windows.pm":

    } elsif (!defined(ref($type))) {

What looks wrong is that 'ref' returns either a a true value (the type) or
else the null string. Doesn't that mean it will ALWAYS be defined (and thus
you'll never pass this condition)? Or does 'ref' return an undefined null
string? Should it be this way?:

    } elsif (!ref($type)) {

otherwise it seems to me that "new MacWindow ID" will NEVER call
GetNewWindow (it will either call GetWindow or else assume you're trying to
register an existing window. So the entire 'new' function should be:

sub new {
    my($class) = shift @_;
    my($type) = @_;
    my($port);

    if (ref($type) eq "Rect") {
        $port = NewWindow(@_) or croak "NewWindow failed";
    } elsif (!ref($type)) {     # <---- should be this way?
        $port = GetNewWindow(@_) or croak "GetNewWindow failed";
    } else {
        $port = $type;
    }
    my(%vars) =
        (port => $port, panes => [], focusable => [], focus => 0,
         idlealways => [], idlefront => [], tabbing => 1);
    $Window{$$port} = bless \%vars, $class;
}

BTW, I can't seem to pass a proper value for BEHIND. I should be able to
pass -1 to put the window in front of all others. How do I cast that as the
proper type? (Finally, I'm doing all this because I had problems with using
the NewWindow form. I couldn't consistently get rid of the grow-icon in my
windows, even when I used the noGrowDocProc window type. Is the proper way
to do this to assign a null procedure?, ie

	$win->sethook("drawgrowicon", sub { return 1})

Obviously, I will send this message and then IMMEDIATELY my mistakes, but I
can't figure this out, so I'll just blame MacPerl... :)

-dan



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