Problem setting position in an Entry



I am trying to make a convenient entry routine for a CSA number, a number on
a state form.

An example CSA would be :   72G/$R/DA/0003/98/00

I am inserting the "/"'s at the appropriate points.  The problem 
comes in in that I am always left with the insertion cursor before the 
slash, here is the code I am using:

void csaEntry( GtkEntry *entry, gchar *text, gint length, gint *position)
{
  gchar slash[] = "/";
  gint newPos;
 
  if( *position == 3 ) {
    newPos = *position + 1;
    gtk_entry_append_text( entry, slash );
    gtk_entry_set_position( entry, newPos );
  }
}

main()
{
	GTKWIDGET *csaName;
...

	csaNum = gtk_entry_new_with_max_length(17);
	gtk_signal_connect_after( GTK_OBJECT( csaNum ), "insert_text",
                      GTK_SIGNAL_FUNC( csaEntry ), "" );
...
}

I understand that I am going to have to deal with insertions in the
middle appending slashes to the end, that I can deal with, however,
I do need to be able to set the position.  I even went so far as to
as to doing entry->current_pos = 4  instead of using set_position, but
this didn't work either.

Can anyone tell me what I am doing wrong?  I guess if all else fails I
could make 6 boxes and have the "/"'s as labels, then I would need to
figure out how to fake a tab at the end of an entry.

Thanks
Roger



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