[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
Gtk.ButtonPressEventHandler(Aussehen_ButtonPressEvent);
Aussehen.Events = Gdk.EventMask.ButtonPressMask; // für
ButtonClick
pop = new Menu();
Gtk.MenuItem menupunkt = new MenuItem("Test");
pop.Append(menupunkt);
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)) {
pop.Popup();
pop.ShowAll();
}
}
thats it. thanks agin.
thomas
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.
>>
>>
>
>http://developer.gnome.org/doc/API/2.0/gtk/gtk-migrating-checklist.html#checklist-popup-menu
>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
>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
>
>