[Gtk-sharp-list] Gnome.CanvasWidget possible bug
Paulo Pires
paulo.pires@vodafone.pt
Sun, 06 Mar 2005 19:06:50 +0000
Hi Manuel and list,
Thanks a lot, that worked out. Still I'm now facing other problem. Here
follows my item.CanvasEvent delegate:
<code>
private void OnCanvasEvent (object o, Gnome.CanvasEventArgs args)
{
Gdk.EventButton ev =3D new Gdk.EventButton (args.Event.Handle);
Gnome.CanvasWidget item =3D (Gnome.CanvasWidget) o;
=09
switch (ev.Type)
{
case Gdk.EventType.ButtonPress:
if (ev.Button =3D=3D 1) {
remember_x =3D ev.X;
remember_y =3D ev.Y;
args.RetVal =3D true;
return;
} else if (ev.Button =3D=3D 3) {
item.Destroy ();
args.RetVal =3D true;
return;
}
break;
=09
case Gdk.EventType.TwoButtonPress:
// change vGrupos info
args.RetVal =3D true;
return;
=09
case Gdk.EventType.MotionNotify:
Gdk.ModifierType state =3D (Gdk.ModifierType) ev.State;
if ((state & Gdk.ModifierType.Button1Mask) !=3D 0)
{
double new_x =3D ev.X, new_y =3D ev.Y;
item.Move (new_x - remember_x, new_y - remember_y);
remember_x =3D new_x;
remember_y =3D new_y;
}
args.RetVal =3D true;
return;
break;
=09
case Gdk.EventType.EnterNotify:
args.RetVal =3D true;
return;
=09
case Gdk.EventType.LeaveNotify:
args.RetVal =3D true;
return;
}
args.RetVal =3D false;
return;
}
</code>
With this code, I was able to take care of all events on my canvas, thus
controlling my Gnome.CanvasPixbuf's (the canvas object I was testing
before I could get CanvasWidget to work), but now it doesn't work out.
It happens that I add the widget and move it around the canvas. After I
drop it, I can no longer move it, delete it, or whatever :/
If you please, take my previous code, add this method and delegate it
like this:
<code>
// this was on the previous code
Gnome.CanvasWidget canvas_widget =3D new
Gnome.CanvasWidget(canvas.Root());
// this is the delegate
canvas_widget.CanvasEvent +=3D OnCanvasEvent;
</code>
Many thanks Manuel
Paulo Pires
Sex, 2005-03-04 =E0s 11:19 -0500, Manuel Alejandro Ceron Estrada escreveu:
> Hi Paulo,
>=20
> Two things:
>=20
> 1. You need to show the Widget which is in the CanvasWidget, if it's a=20
> box you should use ShowAll();
>=20
> 2. You must set Width and Height properties of the CanvasWidget.
>=20
> Your AddWidget should be like this:
>=20
> private void AddWidget()
> {
> VBox v =3D new VBox();
> v.PackStart(new Label("Testing label"), false, false,0);
> v.PackStart(new Button("Testing button"), false, false,0);
> v.ShowAll();
> =09
> Gnome.CanvasWidget canvas_widget =3D new Gnome.CanvasWidget(canvas.Root=
());
> =09
> canvas_widget.Width =3D 100;
> canvas_widget.Height =3D 100;
> =09
> canvas_widget.Widget =3D v;
> canvas_widget.Show();
> }
>=20
> Manuel.
>=20
> Paulo Pires escribi=F3:
> > Hi fellows
> >=20
> > I've done this simple test in order to help knowing if this is a bug or
> > just lammeness :)
> >=20
> > The problem is that Gnome.CanvasWidgetshould be appearing on the
> > Gnome.Canvas and it isn't.
> >=20
> > I'd love to know how to add an Gnome.CanvasItem to the upper-left corne=
r
> > of the canvas, since I'm unable to get it in my tests with
> > Gnome.CanvasPixbuf.
> >=20
> > I'm using Mono 1.1.4 and latest gtk-sharp svn revision.
> > I've compilled and ran the test as follows:
> > mcs -pkg:gtk-sharp,gnome-sharp test.cs
> > mono test.exe
> >=20
> > Thanks in advance,
> > Paulo Pires
>=20