Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Questions regarding Tk::bind

17 views
Skip to first unread message

Oliver 'ojo' Bedford

unread,
Oct 14, 2009, 4:07:41 PM10/14/09
to
Hi!

A) How can I react to the resizing of my main window?

Something like

{{{
$mw->bind('<ResizeRequest>', sub {
print "Resize\n";
});
}}}

doesn't seem to work.

B) I don't really understand the format of the Events. How to I
code KeyPresses of '+' and '-'?

Regards,
Oliver

Steve C

unread,
Oct 14, 2009, 5:55:52 PM10/14/09
to
Oliver 'ojo' Bedford wrote:
> Hi!
>
> A) How can I react to the resizing of my main window?
>
> Something like
>
> {{{
> $mw->bind('<ResizeRequest>', sub {
> print "Resize\n";
> });
> }}}
>
> doesn't seem to work.
>

Not sure what ResizeRequest means, but you are right - it doesn't
activate if the user resizes the window.

You can bind '<Configure>' and then filter out changes that don't
affect the size.


> B) I don't really understand the format of the Events. How to I
> code KeyPresses of '+' and '-'?
>


Really you're only allowed 1 question per post, but we'll
give you a pass this time.

sub WutKey {
my ($self, $key) = @_;
print "Release to $key\n";
}

$Mainwin -> bind('all', "<KeyRelease>" => [\&WutKey, Tk::Ev('K')]);

My keyboard reports 'plus' over 'equal' and 'Kp_add' in the number pad.
So if you want to capture shift-'=' then do

$Mainwin -> bind('all', "<KeyRelease-plus>" => [\&WutKey, Tk::Ev('K')]);

V. Ul. Peculus

unread,
Oct 19, 2009, 2:12:49 AM10/19/09
to
Oliver 'ojo' Bedford wrote:
> Hi!
>
> A) How can I react to the resizing of my main window?
>
> Something like
>
> {{{
> $mw->bind('<ResizeRequest>', sub {
> print "Resize\n";
> });
> }}}
>
> doesn't seem to work.


For me binding to <Configure> works. (But this is also called several
times at startup and at least twice during a resize)

0 new messages