JPaul has asked for the wisdom of the Perl Monks concerning the following question:
I'm using the latest Perl/Tk from CPAN, w/perl 5.6.1, and as well as reading the POD, I've got Advanced Perl Programming and am hovering over the Perl/Tk chapters.
My first task is to bind to keys, which works as so:
However the Advanced Perl Programming documented use of Ev() does not work for me, ala:$MW->bind('<k>', \&CallbackSub);
This returns a HASH object, not the key pressed. By doing the following I can get a SCALAR to be returned - but am not sure how to interpret the scalar:$MW->bind('<Any-KeyPress>', [\&mysub, Ev('k')]);
The next thing thats eluding me is binding the arrow-keys. (What I was hoping Ev() would tell me was the arrow-key ASCII code that I could use to bind them). I figured I'd be smart and bind 8, 6, 4 and 2 and just let keep the NumLock on - but binding those numbers does NOT bind the numeric keypad number keys!$MW->bind('<Any-KeyPress>', sub { &mysub(Ev('k')) });
Who can enlighten me as to whats going on, and how I should go about doing my final object.
JP,
-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --
Edit Masem 2002-02-19 - fixed tags to use CODE instead of font changes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Keyboard input with Perl/Tk's -bind()
by rjray (Chaplain) on Feb 12, 2002 at 00:06 UTC | |
by JPaul (Hermit) on Feb 12, 2002 at 00:54 UTC | |
|
Re: Keyboard input with Perl/Tk's -bind()
by Vavoom (Scribe) on Feb 12, 2002 at 00:17 UTC |