Re: activating a button



Below is a copy of an email that I sent to Davina and forgot to CC the
list. 


The only way that I know of to get the effect of a button being pressed
when a key is pressed is rather messy and involved for what you want to
do. You connect to both the "key_press_event" and the
"key_release_event" of the widget that is going to have the keyboard
focus and in key_press handler call gtk_button_enter(),
gtk_button_pressed(), and gtk_button_clicked(). Then in the key_release
handler use gtk_button_released() and gtk_button_leave(). The problem
with this approach is that if the mouse happens to be over the button
that you're doing this with then you get 2 "clicked" signals emitted so
you need to check to make sure that you're button isn't the widget that
the mouse happens to be over. You can do this by connecting to the
"enter_notify_event" and "leave_notify_event" for the button that you're
dealing with. If it is then don't call gtk_button_enter(),
gtk_button_clicked() and gtk_button_leave(). (I told you it was messy)

I'm not sure how much help this would be to you though. Even on my
slowest machine (pentium 100) a dialog I have that has an entry widget
with button_clicked attached to it's "activate" signal, goes away too
fast to be able to see the visual effect, unless you are not closing the
dialog at this time.

Davina Armstrong wrote:
> 
> I want write a dialog box that does the following:
> 
> It has a GtkEntry and a GtkButton.  When it first appears, the GtkEntry
> has the focus.  The user types in the GtkEntry and hits Enter, which -
> and here's my problem - activates the GtkButton.
> 
> When I hit Enter, the GtkEntry "activate" event is triggered.  I can
> either make the "activate" event call my button callback function, or I
> can make it call gtk_button_clicked(button), both of which work, but
> fail to give the user the visual feedback of the button being clicked.
> Can anyone tell me how to accomplish this?
> 
> Thanks!
> Davina
>




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