gtkEntry, a virtual keyboard and overwriting problems



Hi there,

I wanted to implement a virtual keyboard using individual letter buttons and have the string constructed displayed in the gtkEntry widget.
entry=gtk_entry_new(); // create the entry widget
GdkEvent new_event; // the gdkevent to put

I used the following approach  when a button was clicked :
  gtk_widget_grab_focus(entry);
  new_event.key.window = gtk_widget_get_parent_window(entry);
  new_event.key.keyval = c[0]; // take only the first letter
  gdk_event_put(&new_event);

I found that every time I clicked a letter button, such as 'a', the letter 'a' would be displayed in the entry widget - great ! but .... If I try to add a second letter, such as 'b', the letter 'a' would be overwritten by 'b'. Not so good ! I need to construct strings in the GtkEntry widget ...

can anyone see what I am doing wrong ?

When I use the same approach with the GtkTextView widget it works OK :
entry=gtk_text_view_new (); // create the text view widget

The following works correctly - I can create strings:
  gtk_widget_grab_focus(entry);
  new_event.key.window = gtk_widget_get_parent_window(entry);
  new_event.key.keyval = c[0]; // take only the first letter
  gdk_event_put(&new_event);


The problem with this approach is that it is overly complex, I only want the user to input a single line of text and it is harder to extract the string from the GtkTextView widget ...

any pointers ?
thanks
Matt



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