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

Re: [MacPerl-Toolbox] Event Handling Basics



At 16.27 -0400 1999.04.07, Mark Yannuzzi wrote:
>(I am guessing that a reference to the subroutine draw_it is used due to
>some 'order of execution' issue, for lack of a better term. That is, if one
>were to place a call to draw_it instead, it would try to execute
>immediately, instead of at run-time)

Yes.  You pass a reference and the sub can be called on command.  The idea
is similar to old perl, where you could pass the function name and eval it
later.

  #!perl -wl
  sub foo { print @_ }

  bar('foo');

  sub bar { eval "$_[0] (0..9)" }

Except now we have a much safer and reasonable means:

  #!perl -wl
  sub foo { print @_ }

  bar(\&foo);

  sub bar { &{$_[0]} (0..9) }


>I cannot find the 'sethook()' function (method) in the Mac::Events, or
>Mac::Windows online help (or in the corresponding .pm files). I understand
>the examples of its use, but was wondering if it is documented anywhere?

Mac::Hooks.  :)


>2) The examples in the MacPerl book imply that redrawing a window consists
>of re-executing the subroutine that drew the contents of the window
>initially when the 'redraw' event is detected.  By extension, the
>implication is that one has to have 'control' over the window's contents
>(i.e, have created the window's content in the first place).  Can one update
>(redraw) a window that one has not created the contents, like an "Open" or
>"Save" dialog box?

Not recommended.  You could try it if you are brave.  I don't know how much
you could control it, if at all.


>Specifically, what I am trying to do is update a Navigation Services
>(Navigation.pm) 'NavGetFile' window, and I'm stuck.  I have found that
>simply by placing a dummy event-handling subroutine in the NavGetFile call:
>
>     NavGetFile($defaultLocation, $dialogOptions, $typeList, sub {});
>
>that the dialog box becomes movable and resizable (NavPutFile comes this way
>by default, and also seems to 'announce' itself as such, since Default
>Folder 3.0.1 modifies the navigation buttons, and adds its own).  So, taking
>the advice in Inside Macintosh, I wanted to write a simple subroutine to
>handle the updating of the window.

Ah, that is a little different than dealing with a window you didn't
create, because your function would be, indeed, used by the same "object"
that created the window.

I do not know how to do what you want to do, so I want attempt to help on
the specifics.  :)


>b) Can a MacWindows object utilize all the constants and functions in the
>Mac::Windows module, or only the ones pertaining to it?

Dunno, what are you in particular wondering about?


>b) $macWindow->window "Returns the underlying toolbox GrafPtr" of the
>window, is there a way to take an existing window's GrafPtr and associate it
>with MacWindows object, so the method's defined for the class can be used?
>(I was hoping, praying that my $windowMac = new MacWindow(GetWMgrPort())
>might do it, but I don't think it worked).

Not sure offhand, someone else might know.

Hope this helped in some way, maybe more people can help on other points
you need answers for.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org