Re: Problem stopping signal.



Brian Wagener wrote:
> 
> In my app I have a text box, a GtkEntry, and when certain keys are
> pressed, I don't want anything to be added to the text box such as the
> keypad enter.  So I connected the signal key_press_event for the main
> widget, so I capture all the key-presses, which I handle the input
> unless the GtkEntry is in focus which it then handles the input itself.
> My problem is when I get one of these keys I don't want to print out,
> and the GtkEntry has the focus I can't get it to not put the char into
> the Entry after the callback.  I tried
> gtk_signal_emit_stop_by_name(text_box,"insert_text") but it says that
> there are no current emissions (84) for GtkEntry.  What am I doing
> wrong?

When I wanted to prevent GtkEntry from handling the Return keypress, I
modified gtk_entry_key_press() as follows.  However, I believe that
mucking with the internal workings of widgets is frowned upon...


static gint
gtk_entry_key_press (GtkWidget   *widget,
		     GdkEventKey *event)
{
  ...
  switch (event->keyval)
  {
    ...
    case GDK_Return:
      /*
      return_val = TRUE;
      gtk_widget_activate (widget);
      */
      /* don't handle this event */
      return_val = FALSE;
      break;
    ...
  }
  ...
}




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