Havoc Pennington wrote:
>
> Paul Barton-Davis <[EMAIL PROTECTED]> writes:
> > In message <000701bfbb97$fa709040$[EMAIL PROTECTED]>you write:
> > >Hello,
> > >I've written a little calculator with a numeric pad. I've bound keys to the
> > >buttons signals, I mean that when i press '7' on the keyboard, the button
> > >labeled '7' emits the "clicked" signal, doing the appropriate stuff.
> > >But I expected that the button would really looks like if 'clicked'. I mean
> > >getting the focus, being depressed, changing its color, etc...
> > >I can see that the signal is really emitted, but the look of the button
> > >doesn't change. I've tried to emit all of the possible signals for the
> > >button, added delays to see better, but nothing happened.
> > >
> > >Does anyone has an idea ?
> >
> > my guess it that you're using regular buttons, whose appearance
> > doesn't really change except between a button press and a button
> > release. if you are using the clicked signal, then unless you use a
> > toggle button, i wouldn't expect to see very much.
> >
>
> People request this feature fairly often (key accelerators result in
> visual feedback), but no one has implemented it yet.
>
> Havoc
You can get this effect by attaching a callback to the "key_press_event"
and calling : gtk_button_pressed(), gtk_button_enter() and
gtk_button_clicked.
In a callback for the "key_release_event" you call gtk_button_released()
and gtk_button_leave().
The problem with this is that if the mouse pointer happens to be over
the button that you're doing this with, you will get an extra "clicked"
signal to be called. One way to get around this is to keep track of any
widgets that the mouse might be over by attaching callbacks to the
"enter_notify_event" and "enter_leave_event" of the buttons that you
will be doing this to and keeping track of any button that is in this
state. If the mouse is over the button, then don't call
gtk_button_enter(), gtk_button_clicked() and gtk_button_leave() and it
will work the way you want.
My program gtapecalc does this, http://gtapecalc.sourceforge.net
The relevant code is in callbacks.c
HTH,
Stephen
--
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null