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

Re: Shift key is eaten somwhere. . . . .



Hi --

> > I am having a problem where I can enter lower case text, but upper
> > case text (i.e. with the shift key pressed) disappears.  I am trying
> > to use gtk_im_context_simple as my input method.
> 
> What do you mean "use gtk_im_context_simple"? Widgets
> should be always using a GtkIMMulticontext which will create whatever
> backend input context is needed.

Here's the code.  By the way, I changed the input callback to
gtk_im_multicontext_new() as you suggested, but I still can't get the
capital letters to appear in my gtk_entry widget.  That is, the bug
has not gone away.

-------------------------  Code  ---------------------
static void
gtk_item_entry_init (GtkItemEntry *entry)
{

#ifdef DEBUG
  printf("In gtk_item_entry_init. . . . .\n");
#endif

  entry->justification = GTK_JUSTIFY_LEFT;
  entry->text_max_size = 0;
  GTK_ENTRY(entry)->has_frame = FALSE;

  g_object_unref(G_OBJECT(GTK_ENTRY(entry)->im_context));
  GTK_ENTRY(entry)->im_context = gtk_im_multicontext_new();
  /*  GTK_ENTRY(entry)->im_context = gtk_im_context_simple_new();  */

  g_signal_connect (G_OBJECT(GTK_ENTRY(entry)->im_context),
                    "commit",
                    G_CALLBACK(gtk_entry_commit_cb),
                    entry);
  g_signal_connect (G_OBJECT(GTK_ENTRY(entry)->im_context),
                    "preedit_changed",
                    G_CALLBACK(gtk_entry_preedit_changed_cb),
                    entry);
  g_signal_connect (G_OBJECT(GTK_ENTRY(entry)->im_context),
                    "retrieve_surrounding",
                    G_CALLBACK(gtk_entry_retrieve_surrounding_cb),
                    entry);
  g_signal_connect (G_OBJECT(GTK_ENTRY(entry)->im_context),
                    "delete_surrounding",
                    G_CALLBACK(gtk_entry_delete_surrounding_cb),
                    entry);
}
-------------------------  End code  ---------------------

> > I have traced the program flow around, and it seems that I manage to
> > get to gtk_im_context_simple_filter_keypress -- which detects all key
> > events -- but when the key release event is detected,=20
> > in_hex_sequence =3D=3D 0, and gtk_im_context_simple_filter_keypress
> > returns FALSE without emitting the "commit" signal. =20
> 
> Normal characters are committed on key press not key release. In
> general, pressing a normal keyboard character should commit it
> immediately.

The problem I am seeing is that "commit" is never emitted when I type
a shift character.  It is emitted when I type a normal lowercase character.

> > *  If so, how does a capital letter get committed?  Can you please
> > describe (in general terms) the sequence of events & fcn calls which
> > result in a capital letter getting committed?=20
> 
> There is no difference between capital and non-capital letters.
> My guess is that you aren't feeding the capital letter key press
> events to the input context at all.

So what would eat the capital letter key press events?  They never
make it to my callback.

I have embedded lots of debug printfs into GTK itself to see
what happens as the program accepts keypresses.  Here's the program's
spew when I type a single "T" (i.e. a single capital letter T).  I
have annotated it in several places to point out what is happening where.

------------------------  Spew  ---------------------------
In gtk_main_do_event, received a KEY_PRESS or KEY_RELEASE event.  <== I press shift
In gtk_propagate_event, event->type == KEY_PRESS or KEY_RELEASE
In gtk_widget_event_internal, found KEY_PRESS_EVENT
 Now calling g_signal_emit with KEY_PRESS_EVENT
In gtk_widget_event_internal, found KEY_PRESS_EVENT
 Now calling g_signal_emit with KEY_PRESS_EVENT
In gtk_main_do_event, received a KEY_PRESS or KEY_RELEASE event.  <== I press T
In gtk_propagate_event, event->type == KEY_PRESS or KEY_RELEASE
In gtk_widget_event_internal, found KEY_PRESS_EVENT
 Now calling g_signal_emit with KEY_PRESS_EVENT
In gtk_widget_event_internal, found KEY_PRESS_EVENT
 Now calling g_signal_emit with KEY_PRESS_EVENT
In gtk_main_do_event, received a KEY_PRESS or KEY_RELEASE event.  <== I release T
In gtk_propagate_event, event->type == KEY_PRESS or KEY_RELEASE
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
We have just entered gtk_entry_key_release !!!!
In gtk_entry_key_release, found editable entry.  Calling entry->im_context !!!!
We have just entered gtk_im_context_simple_filter_keypress !!!
In gtk_im_context_simple_filter_keypress, detected key release!
In gtk_im_context_simple_filter_keypress, KEY_RELEASE but no in_hex_seq! Return FALSE.
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
Entering gtk_widget_real_key_press_event . . .
In gtk_main_do_event, received a KEY_PRESS or KEY_RELEASE event.  <== I release shift
In gtk_propagate_event, event->type == KEY_PRESS or KEY_RELEASE
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
We have just entered gtk_entry_key_release !!!!
In gtk_entry_key_release, found editable entry.  Calling entry->im_context !!!!
We have just entered gtk_im_context_simple_filter_keypress !!!
In gtk_im_context_simple_filter_keypress, detected key release!
In gtk_im_context_simple_filter_keypress, KEY_RELEASE but no in_hex_seq! Return FALSE.
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
In gtk_widget_event_internal, found KEY_RELEASE_EVENT
 Now calling g_signal_emit with KEY_RELEASE_EVENT
Entering gtk_widget_real_key_release_event . . .
Entering gtk_widget_real_key_press_event . . .
------------------------  End spew  --------------------------- 

Any ideas why gtk_event_key_press is never invoked? 

Thanks for your observations!

Stuart


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