Re: gtk_widget_set_sensitive and mouse pointer





Eric Masson @ Savant Protection wrote:

Hi All,

I had a small problem that was bugging me for a while, and I figured I'd 
share the results of my findings.

The problem was this:
You have several widgets inside of a container and you call 
gtk_widget_set_sensitive with false to gray out the container + all 
children.  If you leave your mouse positioned over a button inside that 
container, and call gtk_widget_set_sensitive with true, you will no 
longer be able to click on that button.

The explanation is simple, the button widget has not received an enter 
signal after becoming sensitive.

To fix this, do the following after making the widget sensitive:
gint x,y;
GdkWindow *windowUnderMouse=gdk_window_at_pointer(&x,&y);
if(windowUnderMouse){
    GdkEventCrossing e;
    e.type=GDK_ENTER_NOTIFY;
    e.window=windowUnderMouse;
    e.send_event=1;
    e.subwindow=0;
    e.time=GDK_CURRENT_TIME;
    e.x=0;
    e.y=0;
    e.x_root=0;
    e.y_root=0;
    e.mode=GDK_CROSSING_NORMAL;
    e.detail=GDK_NOTIFY_UNKNOWN;
    e.focus=true;
    e.state=0;
    gdk_event_put((GdkEvent *)&e);
}



That big chunk of code is not required.  Just hide, then show, the widget
that was set sensitive (noted as a work-around in the bug report).
-- 
View this message in context: 
http://www.nabble.com/gtk_widget_set_sensitive-and-mouse-pointer-tp18444013p18489265.html
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.




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