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 = new Gdk.EventButton (args.Event.Handle);
  Gnome.CanvasWidget item = (Gnome.CanvasWidget) o;
                
  switch (ev.Type)
  {
  case Gdk.EventType.ButtonPress:
  if (ev.Button == 1) {
        remember_x = ev.X;
        remember_y = ev.Y;
        args.RetVal = true;
        return;
  } else if (ev.Button == 3) {
        item.Destroy ();
        args.RetVal = true;
        return;
  }
  break;
                                
  case Gdk.EventType.TwoButtonPress:
        // change vGrupos info
        args.RetVal = true;
        return;
                                
  case Gdk.EventType.MotionNotify:
        Gdk.ModifierType state = (Gdk.ModifierType) ev.State;
        if ((state & Gdk.ModifierType.Button1Mask) != 0)
        {
                double new_x = ev.X, new_y = ev.Y;
                item.Move (new_x - remember_x, new_y - remember_y);
                remember_x = new_x;
                remember_y = new_y;
        }
        args.RetVal = true;
        return;
        break;
                                
  case Gdk.EventType.EnterNotify:
        args.RetVal = true;
        return;
                                
  case Gdk.EventType.LeaveNotify:
        args.RetVal = true;
        return;
  }

args.RetVal = 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 = new
Gnome.CanvasWidget(canvas.Root());

// this is the delegate
canvas_widget.CanvasEvent += OnCanvasEvent;

</code>

Many thanks Manuel
Paulo Pires


Sex, 2005-03-04 �s 11:19 -0500, Manuel Alejandro Ceron Estrada escreveu:
> Hi Paulo,
> 
> Two things:
> 
> 1. You need to show the Widget which is in the CanvasWidget, if it's a 
> box you should use ShowAll();
> 
> 2. You must set Width and Height properties of the CanvasWidget.
> 
> Your AddWidget should be like this:
> 
> private void AddWidget()
>       {
>               VBox v = new VBox();
>               v.PackStart(new Label("Testing label"), false, false,0);
>               v.PackStart(new Button("Testing button"), false, false,0);
>               v.ShowAll();
>               
>               Gnome.CanvasWidget canvas_widget = new 
> Gnome.CanvasWidget(canvas.Root());
>               
>               canvas_widget.Width = 100;
>               canvas_widget.Height = 100;
>               
>               canvas_widget.Widget = v;
>               canvas_widget.Show();
>       }
> 
> Manuel.
> 
> Paulo Pires escribi�:
> > Hi fellows
> > 
> > I've done this simple test in order to help knowing if this is a bug or
> > just lammeness :)
> > 
> > The problem is that Gnome.CanvasWidgetshould be appearing on the
> > Gnome.Canvas and it isn't.
> > 
> > I'd love to know how to add an Gnome.CanvasItem to the upper-left corner
> > of the canvas, since I'm unable to get it in my tests with
> > Gnome.CanvasPixbuf.
> > 
> > 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
> > 
> > Thanks in advance,
> > Paulo Pires
> 

_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to