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

[MacPerl] Doh! or, How not to clear the MacPerl window.



Before everyone flames me, I figured out why I was getting the error with
the assignments to the members of ToolboxEvent. I should have called them
as methods with the values of the assigments as arguments.

I'm not having any luck trying to build an event and pass it to
DispatchEvent. I've gotten past the original error, but I'm getting many
others. I'm giving up on that route. Pardon my ramblings, but I'm thinking
as I type and experiment with code.

I know there's a Toolbox call to post an event on the queue, but I'm too
lazy to whip out my Inside Macintosh. I also don't believe that MacPerl
exposes the Toolbox at that low of a level. (Kinda goes against the
scripting philosophy, no?)

I like the idea of using EraseRect() and having given it a bit more
thought, would probably do something like this:

use Mac::QuickDraw;
use Mac::Windows;
sub clear_window($)
{
	my $win = $_[0];
	my $save_port = GetPort();
	SetPort($win);
	EraseRect($win->portRect());
	MoveTo(0, 0);
	SetPort($save_port);
}

If you run MacPerl in the front and call the above as
&clear_window(FrontWindow()); it succeeds in clearing the MacPerl output
window. (As I'm sure other Mac Programmers will point out, that is a
dangerous thing to do.) It also blows away the scrollbar, but I expected
that to happen.

However, the code above only works until the MacPerl output window is
updated. So it appears to do nothing once you start printing again, or if
you move or resize the window, or click in another window etc.

I'm at a loss. I'm obviously having problems with calling stuff from some
of the packages (a minor Perl issue, no need to discuss it further here),
and I'm forgetting that your script doesn't have control over the MacPerl
output window, so you can't really clear it programmatically with Toolbox
calls. If you do, it will just redraw itself at the next updateEvt.

The above code would work with your own window, but then you lose the
convenience of having MacPerl handle all of your output.

Has anyone tried printing a form feed character? :-)
+----------------------------+-----------------------------+
|     Jason Stephenson       |        panda@mis.net        |
+----------------------------+-----------------------------+
| There are no guarantees in life, the Tao or programming. |
|                      --Bruce Eckel                       |
+----------------------------------------------------------+

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