Ejemplo n.º 1
0
        public void Show(Gtk.Widget parent, Gdk.EventButton evt)
        {
                        #if MAC
            if (Platform.IsMac)
            {
                ContextMenuExtensionsMac.ShowContextMenu(parent, evt, this);
                return;
            }
                        #endif

            ContextMenuExtensionsGtk.ShowContextMenu(parent, evt, this);
        }
Ejemplo n.º 2
0
        public void Show(Gtk.Widget parent, int x, int y, Action closeHandler, bool selectFirstItem = false)
        {
                        #if MAC
            if (Platform.IsMac)
            {
                ContextMenuExtensionsMac.ShowContextMenu(parent, x, y, this, closeHandler, selectFirstItem);
                return;
            }
                        #endif

            ContextMenuExtensionsGtk.ShowContextMenu(parent, x, y, this, closeHandler, selectFirstItem);
        }
Ejemplo n.º 3
0
        public void Show(Gtk.Widget parent, int x, int y, Action closeHandler, bool selectFirstItem = false)
        {
                        #if MAC
            if (Platform.IsMac)
            {
                int tx, ty;

                // x, y are in gtk coordinates, so they need to be translated for Cocoa.
                parent.TranslateCoordinates(parent.Toplevel, x, y, out tx, out ty);
                ContextMenuExtensionsMac.ShowContextMenu(parent, tx, ty, this, closeHandler, selectFirstItem);
                return;
            }
                        #endif

            ContextMenuExtensionsGtk.ShowContextMenu(parent, x, y, this, closeHandler, selectFirstItem);
        }
Ejemplo n.º 4
0
        protected override void OnClicked()
        {
            base.OnClicked();
            if (contextMenuCreator != null)
            {
                ContextMenu menu      = contextMenuCreator(this);
                var         oldRelief = MenuOpened();

                Gdk.Rectangle rect = this.Allocation;

                // Offset the menu by the height of the rect
                ContextMenuExtensionsGtk.ShowContextMenu(this, 0, rect.Height, menu, () => MenuClosed(oldRelief));
                return;
            }

            if (creator != null)
            {
                Menu menu = creator(this);

                if (menu != null)
                {
                    var oldRelief = MenuOpened();

                    //clean up after the menu's done
                    menu.Hidden += delegate {
                        MenuClosed(oldRelief);

                        //FIXME: for some reason the menu's children don't get activated if we destroy
                        //directly here, so use a timeout to delay it
                        GLib.Timeout.Add(100, delegate {
                            menu.Destroy();
                            return(false);
                        });
                    };
                    menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime);
                }
            }
        }