[Gtk-sharp-list] Popup menu on DrawingArea

Thomas Zühlke muell_muell_@gmx.net
Tue, 19 Apr 2005 22:17:12 +0200

okay, i got it. thanks. the sample you have send is too complex, but
with it i can make an easier way:
i have a Gtk.DrawingArea called "Aussehen" and a Gtk.Menu called "pop"
and declaring inside the constructor:
            Aussehen.ButtonPressEvent += new
            Aussehen.Events = Gdk.EventMask.ButtonPressMask; // für

            pop = new Menu();
            Gtk.MenuItem menupunkt = new MenuItem("Test");

and then the funktion "Aussehen_ButtonPressEvent":
        void Aussehen_ButtonPressEvent(object o,
Gtk.ButtonPressEventArgs args) {
            if((args.Event.Button == 3)&&(args.Event.Type ==
Gdk.EventType.ButtonPress)) {
thats it. thanks agin.

Dan Winship wrote:

>On Tue, 2005-04-19 at 12:26 +0200, Thomas Zühlke wrote:
>>Hi *,
>>i must assign a Popup-Menu to a DrawingArea. And i can't find any help
>>in Mono-Doc or a Gtk-Sample. I have already used a menu in a Gtk.Window
>>and this works fine, but i haven't any idea how to assign a Popup-Menu
>>to Gtk.DrawingArea.
>shows what to do in C. Basically you need to connect to the
>ButtonPressEvent and PopupMenu signals, create a Gtk.Menu, and call
>Popup on it. (If you are subclassing DrawingArea, you'd do this by
>overriding OnButtonPressEvent and OnPopupMenu.)
>-- Dan
>Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com