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

Re: [MacPerl-Toolbox] forewarding events



Marion Blatter writes Tue, 06 Jul 1999 22:55:40 +0200:

>My Problem is that I can't forward an event if I don't want
>to handle it. To demonstrate the problem I wrote a tiny script in which a
>dialog box is displayed with nine editing fields. The keyDown event is
>led to a soubroutine:
>
>   $Mac::Events::Event[keyDown] = \&changeEditField;
>
>which makes it possible to redefine the cursor buttons, allowing you to
>shift the activated editing field in all four directions.
>The way I understand it, editing fields in a dialog box should still be
>editable, automatically using the code at the bottom of the message, but
>with the following soubroutine as replacement:

[snip]

There are really two issues here:

        a)  advancing the focus from one edit field to another
        b)  editing text in the field with the focus

Both of these functions are built Windows.pm with the aid of Dialogs.pm or
TextEdit.pm.

Firstly text edit fields set up using Dialogs or TextEdit are registered as
focusable panes in the MacWindow and the focus can be advanced by the TAB
key, or selected by a mouse click in the field. (Look at subroutine 'key()'
in Windows.pm. to see how this is done.) Mostly this is all that is needed.

Secondly text edit fields set up using Dialogs are genuine 'TextEdit'
fields, i.e. fields that automatically provide you with the Toolbox 'TE
Manager' functions.

The script below will probably do most of what you want. Experiment with
the Tab key, the Arrow keys, the Delete key, text selection, 'Cut', 'Copy'
and 'Paste' and mouse-clicks to select fields or position the caret.

There are two minor bugs. One bug is that Shift-TAB does not step backwards
as it should. The other bug is more serious, namely if you run the Dialog
non-modally (i.e. omitting the line '$dlg->modal') the MenuBar is not
revised and use of 'Cut', 'Copy' or 'Paste' will cause a machine crash.

I hope this is some help.

Alan Fry

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

#!perl

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

$box = Rect->new(0, 0, 50, 15);
$win = Rect->new(20, 50, 230, 145);

$dlg = MacDialog->new($win,"", 1, 4, 1, (
    [ kEditTextDialogItem, OffsetRect($box,  10, 10), '' ],
    [ kEditTextDialogItem, OffsetRect($box,  10, 40), '' ],
    [ kEditTextDialogItem, OffsetRect($box,  10, 70), '' ],
    [ kEditTextDialogItem, OffsetRect($box,  80, 10), '' ],
    [ kEditTextDialogItem, OffsetRect($box,  80, 40), '' ],
    [ kEditTextDialogItem, OffsetRect($box,  80, 70), '' ],
    [ kEditTextDialogItem, OffsetRect($box, 150, 10), '' ],
    [ kEditTextDialogItem, OffsetRect($box, 150, 40), '' ],
    [ kEditTextDialogItem, OffsetRect($box, 150, 70), '' ],
  )
);

$dlg->modal;
WaitNextEvent while $dlg->window;

dispose $dlg;

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



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