RE: Problems with Gtk::Text and set_pointer and Text widget quest ions

I got to reading the tutorial on signal handlers again, and you need to use
signal_connect_after if you want your signal handler to appear to have an
effect when there is a default signal handler for the widget.  In this case,
I was able to get the result Michel discribes by using the following:

$text->signal_connect_after ("button_press_event" => \&button_press);

I also changed the signal handler to insert a space and then delete it at
the insertion point.  This seems to be the only way to actually get the Text
widget to move the cursor.  It isn't elegant, but it works.

sub button_press
        my ($text, $event) = @_;
        my $len = $text->get_length()-1;
        $text->set_point ($len +1);
        $text->insert ('','','',' ');
        $text->backward_delete (1);


David P. Fannin
Database Administrator                                  dpf umr edu
UM-Rolla Computing and Information Services      FAX (573) 341-4216
URL                   PHONE (573) 341-4841

-----Original Message-----
From: Michel Blanc [mailto:mblanc erasme org]
Sent: Tuesday, August 14, 2001 9:14 AM
To: Fannin, David P.
Cc: gtk-perl-list gnome org
Subject: Re: Problems with Gtk::Text and set_pointer and Text widget

"Fannin, David P." a écrit :


Before I post this to the Gtk list, I want to make sure I understand the
documentation myself.  It looks like the set_point routine is used to move
the insertion point to an arbitrary place.  I changed the code such that
clicking on one of the checkboxes called $text->set_point(4) and then
inserted text.  This worked without a problem.  However, when linking the
button_press routine to a button press associated with the Text widget, it
didn't work.  When I got to thinking about it, though, pressing the mouse
button in a Text widget probably calls set_point to move the insertion
to where the mouse is.  I'm not sure it makes sense to call set_point in
association with a button_press event with the Text widget.  Maybe it
help if you described what you're trying to do, because right now I'm

Yes you're right.
What I am trying to do is some kind of "shell" interface in a text
Thus, whenever the widget is activated, or wherever the user clicks, I
want the cursor (and insertion point, since it seems I wrongly confuse
both terms) to be set after a prompt, tht is, at the end of the text in
the widget.
For now, I can't achieve this, since I can click anywere, and type text
there, garbling the display. The only solution for now is to have a
separate widget to enter the commands, and another (not editable) to
display it. Not very convenient !


Michel Blanc
Centre Multimédia Erasme/Parc d'activités innovantes
69930 Saint Clément-les-places
Tel : +33-(0)4-74-70-68-40 / Fax : +33-(0)4-74-70-68-40

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]