Re: combo box



On Mon, 1 Oct 2001, Paul Davis wrote:

> > my_func is signal handler for both - key press and key_release
> >events, but only key_press is active all the time
>
> I noted on the list a week or so ago that a number of widgets only
> receive key_press by default. you need to use gtk_widget_add_events()
> if you want key_release as well.
>
> >release never appears and after press <Up> focus goes out (it goes out
> >right afrer key_press, before release <Up> button !)
>
> yep, thats the way the built-in focus handlers work.
>
> >if i remove
> >gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_release_event")
> >- no more Gtk-Warnings, but focus goes out of combo's entry area.
>
> did you conditionalize the stop_by_name() on the type of event? you
> should have:
>
>        gint my_callback (GtKWidget *w, GdkEventKey *event, gpointer data)
>        {
>             ...
> 	    switch (event->type) {
> 	    case GDK_KEY_PRESS:
> 	         gtk_signal_emit_stop_by_name (w, "key_press_event");
> 		 break;
> 	    case GDK_KEY_RELEASE:
> 	         gtk_signal_emit_stop_by_name (w, "key_release_event");
> 		 break;
>             default:
> 		 break;
>             }
> 	    return TRUE;
>       }
>
> --p

ok, lets go from the way begining:

1. i create combo box:

combo2 = gtk_combo_new ();

and assign signal handler:

gtk_signal_connect_object(GTK_OBJECT (GTK_ENTRY(GTK_COMBO(combo2)->entry )) , "key_press_event", GTK_SIGNA
L_FUNC(my_func),GTK_OBJECT (GTK_ENTRY(GTK_COMBO(combo2)->entry)));

2. inside my_func

void my_func (GtkWidget* widget, GdkEventKey* event, gpointer data)

 ev = event->type;

 printf ("event->type = %d\n", ev); - get 8 all the time (key_pressed)

 switch (event->keyval) {
        case GDK_Up:
	... do smth. usefull...

	and try to stop emission to prevent <Up> focus-out:

gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");


no errors, but after press <Up> focus goes out (it hapened before !!!
release <Up> )

i tried also return TRUE | FALSE instead of void.


question is: why signal "key_pressed" doesn't stop and goes further to
focus-handler?



PS: i partially solved this problem by using
    gtk_combo_disable_activate(GTK_COMBO(combo1));
    gtk_combo_set_use_arrows_always (GTK_COMBO(combo1), TRUE);
    in developer version, but it's not what i'd like to :(

PPS: you can see all the src here: www.enlight.ru/ptkdic/


any ideas?



---
See you later...
                             Alexey.





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