[Gtk-sharp-list] ButtonPressEvent on TreeView

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

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!


> 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?
> 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;
  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.
    return true;

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

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

Version: GnuPG v1.2.3 (GNU/Linux)