in reply to Re: Weirdness with Tk::Text
in thread Weirdness with Tk::Text

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

Replies are listed 'Best First'.
Re: Re: Re: Weirdness with Tk::Text
by meredith (Friar) on Jun 19, 2003 at 12:23 UTC
    I don't see anything wrong, though I may have overlooked something. Since I don't have a Tk::BrowseEdit, I can't do quite perfect testing of what you're doing. Similar code works fine for me, using AS 806 and Tk 800.024 Maybe another monk can see what's wrong, or maybe it's an issue with the module? :/

    mhoward - at - hattmoward.org
      well, i wrote the module myself, so that would explain why you don't have it. :)

      i also don't see anything wrong with the code, but i keep getting those double characters. full source code is available at http://milkbone.org.

        Ah! Milkbone! I could tell you were doing messaging, but assumed it wasn't a public project.

        Alright. I'm running it, logged on, and messaging myself (no friends ;) I am not seeing any problems with the input box... same platform as mentioned before, Windows 2000. Think it is an issue with their versions???

        mhoward - at - hattmoward.org