[Gtk-sharp-list] ButtonPressEvent on TreeView

Mikael Hallendal micke@imendio.com
Mon, 05 Apr 2004 06:31:42 +0200


--=-M5Y3P475UaDLVApywh26
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On s=C3=B6n, 2004-04-04 at 23:47 +0200, Daniel Pecos wrote:=20
> Hello!

Hi,

> I'm trying to develop a simple app that uses a treeview and I want to
> add context menus, so I need ButtonPressEvent, isn't it?
>=20
> I have read FAQ 3.3, but I can't get it working. Could anyone show me a
> working example?

something along the lines of this should do:

public class YourTree : Gtk.TreeView {

  static GLib.GType gtype =3D GLib.GType.Invalid;
  public static new GLib.GType GType {
    get {
      if (gtype =3D=3D GLib.GType.Invalid)
        gtype =3D RegisterGType (typeof (YourTree));
      return gtype;
    }
  }
       =20
  public YourTree () : base (GType)=20
  {
    // Constructor code
  }

  protected override bool OnButtonPressEvent (EventButton event)
  {
    switch (event.Button) {
    case 1:=20
      // Let the treeview implementation handle left click
      return base.OnButtonPressEvent (event);
    case 3:
      // Popup your context menu
      return true; // Prevents other handlers from receiving the event.
    }
=20
    return true;
  }
}

Good luck,
  Mikael Hallendal
--=20
Imendio HB, http://www.imendio.com/


--=-M5Y3P475UaDLVApywh26
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Detta =?ISO-8859-1?Q?=E4r?= en digitalt signerad
	meddelandedel

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBAcOEucCUF7/xF8ZsRAtCPAKDGi33e62P3wI5pIXlBHFWUuQPVjgCdHK3X
8J3+mvEizRNFWXfxPWjQAo8=
=JYaQ
-----END PGP SIGNATURE-----

--=-M5Y3P475UaDLVApywh26--