Re: Hiding a Widget & Keeping the Events Running
- From: Jan-Marek Glogowski <glogow fbihome de>
- To: Marshall Lake <mlake mlake net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Hiding a Widget & Keeping the Events Running
- Date: Sun, 1 Aug 2004 22:26:03 +0200 (CEST)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ok - some code, which works here - when clicked the label changes
visibility.
#include <gtk/gtk.h>
gboolean eventbox_button_press
(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
GtkWidget *event_widget = GTK_WIDGET( user_data );
if( GTK_WIDGET_VISIBLE( event_widget ) )
gtk_widget_hide( event_widget );
else
gtk_widget_show( event_widget );
return FALSE;
}
int
main( int argc,
char *argv[])
{
GtkWidget *event, *label, *window;
gtk_init( &argc, &argv );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
g_signal_connect( G_OBJECT( window ),
"destroy", G_CALLBACK( gtk_main_quit ), NULL);
event = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER( window ), event );
label = gtk_label_new("Hello");
gtk_container_add( GTK_CONTAINER( event ), label );
g_signal_connect( event, "button_press_event",
G_CALLBACK( eventbox_button_press ), label );
gtk_widget_show_all( window );
gtk_main();
return 0;
}
The GtkLabel is special, since it can't receive events, because it has no
own window. If the child widget has a window you should be able to simply
connect a handler to the widget, which hides it, and a handler to the
event box, which shows it.
The table shouldn't have any influence...
HTH
Jan-Marek
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBDVHdj6MK58wZA3cRAkdDAJ9BwfipLyt72mgkPrwkr57IsGr43ACeNbHR
J7kU7fg/LhRfaaeasIZMy9I=
=oAbx
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]