gtk_editable_select_region and cursor position



Hi,

Came across this problem in gtk and not sure if solveable...

Scenario :

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
gdk_editable_get_position()
is the end of the string as opposed to where the next char is typed.

e.g.
        List of Previously entered strings :
                string1
                sring1
                sing1

        Order of entry

        1. type "s"
                Within the key_press_event callback
        
                gtk_editable_get_position -> 0
                
           I match the string "sing1"

                gtk_entry_set_text("sing1");
                gtk_editable_set_position(current_position+1);
                gtk_editable_select_region(current_position+1, -1);

           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
wrong..

Thanks

Matt


-- 
        __.--'\     \.__./     /'--.__
    _.-'       '.__.'    '.__.'       '-._
  .'       Matt Keenan (mattman)          '.
 /       Sun Microsystems Ireland           \
|                                            |
|   E-Mail : Matt Keenan Sun Com             |
|            mattman iol ie                  |
|                                            |
|  Irish Fantasy League Of American Football |
|           http://www.iflaf.com             |
|                                            |
|        Happy Hookers Golf Society          |
|   http://www.iol.ie/~mattman/golf/hhgs.htm |
|                                            |
|   Phone  : +353 1 8199251, Sun Ext : 19251 |
 \         .---.              .---.         /
  '._    .'     '.''.    .''.'     '.    _.'
     '-./            \  /            \.-'
                      ''



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