Ben Motmans wrote:
On 4/22/05, Milen Dzhumerov <[EMAIL PROTECTED]> wrote:
Hi all,
I've been reading Mono: A Developer's Notebook and I couldn't find a way of creating an icon with a stock image. I looked at www.go-mono.com/docs/ for Icon related classes but couldn't figure out how to do it. My other question is, is it possible to show a menu if the user clicked on the icon?
Regards,
gamehack
You don't need to use the Icon class, but the Image class Image img = new Image("gtk-save", IconSize.Menu);
It is also possible to show a menu if a user clicks on the image, but you need to add the Image to an EventBox, since an Image cannot fire events
EventBox eb = new EventBox(); EventBox.Add(new Image("gtk-save", IconSize.Menu); EventBox.ButtonPressEvent += new ButtonPressEventHandler (OnImageClick);
private void OnImageClick (object o, ButtonPressEventArgs args) { if (args.Event.Button == 3) { //right click Menu popupMenu = new Menu(); MenuItem menuPopup1 = new MenuItem ("Popup item 1"); popupMenu.Add (menuPopup1); popupMenu.Popup (null, null, null, IntPtr.Zero, args.Event.Button, args.Event.Time);
popupMenu.ShowAll (); } }
But are you sure you really want a stock image with a menu popping up if the user clicks the image? there are nice ways of doing someting similar, like a Toolbar with a Gtk.MenuToolButton (some sort of combo box) or ...
-- Ben _______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Well,
I want to use this for a tray icon. Here's the sample code - http://www.1nsp1r3d.co.uk/tmp/mono/TrayIcon.cs. I want to replace this line:
icon.Add (new Label ("Testing"));
with your code, but I'm not sure whether it will work out. And as a side not, I couldn't find the method documented anywhere.
Regards, gamehack
_______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list