[Gtk-sharp-list] Run Window as Modal Dialog
Mariano Benedettini
mbenedettini at ad-net.us
Thu Dec 22 12:42:21 EST 2005
Hello,
I've done something similar, setting the parent window as transient for
the child one.
A problem I found is that, unless I grab keyboard and mouse for the
child window, the keyboard cursor doesn't show properly.
[...]
[Widget] private Gtk.Window windowParent;
[Widget] private Gtk.Window windowChild;
[...]
private void BuildProperties()
{
windowChild.TransientFor = windowParent;
windowParent.Realize();
windowChild.Realize();
windowChild.ShowAll();
windowParent.ShowAll();
SetGrabbing(windowChild, false);
windowChild.Move( 100, 300);
}
private bool SetGrabbing(Widget widget, bool confined)
{
Gdk.Window widgetGdkWin = widget.GdkWindow;
Gdk.Window widgetConfinedGdkWin;
if (confined) {
widgetConfinedGdkWin = widget.GdkWindow;
} else {
widgetConfinedGdkWin = null;
}
Grab.Add(widget);
if (Gdk.Keyboard.Grab(widgetGdkWin, true, 0) != Gdk.GrabStatus.Success)
{
Grab.Remove(widget);
return false;
}
if (Gdk.Pointer.Grab(widgetGdkWin, true, Gdk.EventMask.ButtonPressMask
| Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask,
widgetConfinedGdkWin, null, 0) != Gdk.GrabStatus.Success)
{
Console.WriteLine("Grab de mouse no conseguido.");
Grab.Remove(widget);
Gdk.Keyboard.Ungrab(0);
return false;
}
return true;
}
Both windows are in the same glade file.
HTH :-)
Mariano.
Evgeny Pirogov wrote:
> Hello.
>
> If possible, I need simple example for running Gtk.Window instance as
> modal dialog for other Gtk.Window.
>
> Thanks.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
--
Mariano Benedettini
Ad Network SA
mbenedettini at ad-net.us
More information about the Gtk-sharp-list
mailing list