Re: gtk_editable_select_region and cursor position
- From: Owen Taylor <otaylor redhat com>
- To: Matt Keenan <Matt Keenan sun com>
- Cc: Gtk App Devel List <gtk-app-devel-list gnome org>
- Subject: Re: gtk_editable_select_region and cursor position
- Date: 24 Apr 2003 12:54:41 -0400
On Thu, 2003-04-24 at 06:47, Matt Keenan wrote:
Came across this problem in gtk and not sure if solveable...
Trying to implement command history within a gtkentry. As you are entering
text I want to be able to display a match from a list of previously entered
strings. I monitor the key_press_event on the GtkEntry widget, and get the
current text position, attempt to make a match and if there is a match
disply this match with the extra text highlighted, however when the user
enters the next key the current position returned from
is the end of the string as opposed to where the next char is typed.
List of Previously entered strings :
Order of entry
1. type "s"
Within the key_press_event callback
gtk_editable_get_position -> 0
I match the string "sing1"
This displays the text "s" unhighlighted and the rest "ing1" highlighted.
2, type "i"
The "i" appears directly after the previously typed "s" which is as
i expect however
gtk_editable_get_position -> 5
surely it should return 1....
Can anyone answer me as to why this is happening, or am I doing something
Hard to say what's going on without seeing a small standalone test case;
I would suggest that you shouldn't be doing stuff off of key_press_event
(that won't work when you have internationalization and input methods),
but rather off of ::insert_text.
If you look at gtkfilechooser/gtkfilechooser.c, you'll find something
similar. (Though it's certainly a little complex for an example...)
What I ended up doing there was to install an idle handler in
insert_text, where the idle handler checked for completions.
] [Thread Prev