They're using Perl 5.8 Build 804. I've determined that this only happens in my code. I do have a binding on KeyPress, but the problem persists even with thatgone.
Here's the code that initializes the Text widget $self->{bottom}: (BrowseEdit is derived from Tk::Text and makes bindings on <Control-B>, <Control-U>, and <Control-I>
$self->{bottom} = $self->{frame}->Scrolled("BrowseEdit",
-height => 6, -font => "times 12", -scrollbars => 'oe', -wrap
+=> 'word',
-spacing1 => 0, -spacing2 => 0, -spacing3 => 0)->
pack(-expand => 1, -fill => 'both', -padx => 5);
$self->{typing} = $self->{frame}->Label->pack(-anchor => 'w');
$self->{frame}->Button(-text => "Send", -command => [$self, "on_se
+nd"])->
pack(-pady => 3, -side => 'right', -anchor => 'center');
$self->{frame}->Button(-text => "Get Profile", -command => [$self,
+ "on_prof"])->
pack(-pady => 3, -side => 'left', -anchor => 'center');
# WIDGET CREATION END
$self->{top}->tagConfigure('self', -foreground => 'red', -font =>
+'times 12 bold');
$self->{top}->tagConfigure('buddy', -foreground => 'blue', -font =
+> 'times 12 bold');
$self->{top}->tagConfigure('self_stamp', -foreground => 'red', -el
+ide => 1, -font => 'times 9 bold');
$self->{top}->tagConfigure('buddy_stamp', -foreground => 'blue', -
+elide => 1, -font => 'times 9 bold');
$self->{bottom}->bind("<Return>", [$self, "on_send"]);
$self->{bottom}->bind("<Escape>", [$self, "destroy"]);
$self->{bottom}->bind("<KeyPress>", [$self, "on_key"]);
$self->bind("<F2>", [$self, "toggle_stamps"]);
$self->{top}->bind('<MouseWheel>',
[ sub { $_[0]->yview('scroll', -($_[1] / 120), 'units') }, Tk:
+:Ev('D')]);
$self->{bottom}->bind('<MouseWheel>',
[ sub { $_[0]->yview('scroll', -($_[1] / 120), 'units') }, Tk:
+:Ev('D')]);
# $self->bind('<Configure>', [sub {
# my ($width, $height) = @_;
# set_option('ConvoHeight', $height);
# set_option('ConvoWidth', $width);
# }, Ev('w'), Ev('h')]);
$self->{bottom}->configure(-background => 'white');
$self->{me} = data("me");
$self->{buddy} = $buddy;
$self->{empty} = 1;
$self->{last_typed} = time;
$self->{typing_status} = 0;
$self->update;
$self->geometry("480x320");
$self->deiconify;
hook("tk_seticon", -wnd => $self);
$self->OnDestroy([$self, "on_destroy"]);
$self->{bottom}->focus;
$self->{rep_id} = $self->repeat(1000, [$self, "update_status"]);
and here's the code for on_key:
sub on_key
{
my ($self) = @_;
print "in handler\n";
if($self->{typing_status} == 0)
{
print "key change\n";
hook("protocol_set_typing_status", -user => $self->{buddy}, -s
+tatus => 2);
$self->{typing_status} = 2;
}
$self->{last_typed} = time;
}
and for update_status:
sub update_status
{
my ($self) = @_;
print "in update\n";
if($self->{bottom}->get('0.0', 'end') =~ /^\s*$/ && $self->{typing
+_status})
{
hook("protocol_set_typing_status", -user => $self->{buddy}, -s
+tatus => 0);
$self->{typing_status} = 0;
return;
}
if((time - $self->{last_typed}) >= 5 && $self->{typing_status} ==
+2)
{
hook("protocol_set_typing_status", -user => $self->{buddy}, -s
+tatus => 1);
$self->{typing_status} = 1;
}
}
I still get these repetitions even when I disable the KeyPress binding and the repeat timer. Again, this doesn't happen outside of my Tk app.
TIA,
Bill |