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

[MacPerl] A question about Mac::Windows



I am trying to open a new window, write some lines of text in it, select
part of the text and return the selection to the program. Is that possible?


I have got a little way with this:

#!perl
use Mac::Windows;
use Mac::QuickDraw;

$rec = new Rect(50, 50, 300, 200);
$win = new MacWindow($rec, "hello", 1, documentProc, 1);
$ptr = $win->{port};                                 ^----- ??

getc;             # pause for breath

SetPort($ptr);
MoveTo(0, 0);
LineTo(100, 100);
DrawString("Goodbye");

getc;             # pause to admire handiwork

dispose $win;     # seems to work, but is it right?


A number of questions arise.

Firstly, if the first getc() pause is omitted, the drawing flashes briefly
in the window and then disappears. Why is this? How can one stop it doing
that (apart from a sleep() or a getc() pause)?

Secondly, how can one replace the second getc() pause with a
"WaitNextEvent" in which text in the window could be selected?

At the first pause, the MacPerl window is brought to the front. I guessed
that maybe <HiliteWindow($ptr, fHilite);> would bring the new window back
to the front, but it doesn't. What would? And what does HiliteWindow()
actually do?

A new MacWindow() behaves, as its name implies, as a Mac window -- the
close box and the zoom box work and the window can be dragged. A
NewWindow() on the other hand is quite 'dead' in those respects. As a
matter of interest, does anyone know how to breath 'life' into a
NewWindow()? In a sense it's the same question as before -- how do you do a
"WaitNextEvent"? How do you field a click in the close box for instance?

Any hints or pointers would be gratefully received.

Alan Fry





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