예제 #1
0
        protected override void ShowPopupMenu(Gdk.Event ev)
        {
            Gtk.Menu menu = new Gtk.Menu();
            for (int i = 0; i < ObjectGroupEditor.ObjectNames.Length; i++)
            {
                if (i >= 2 && i <= 4) // Skip "Pointer" objects
                {
                    continue;
                }
                Gtk.MenuItem item = new Gtk.MenuItem("Add " + ObjectGroupEditor.ObjectNames[i]);
                menu.Append(item);

                int index = i;

                item.Activated += (sender, args) => {
                    SetSelectedIndex(ObjectGroup.AddObject((ObjectType)index));
                };
            }

            if (HoveringIndex != -1)
            {
                menu.Append(new Gtk.SeparatorMenuItem());

                Gtk.MenuItem deleteItem = new Gtk.MenuItem("Delete");
                deleteItem.Activated += (sender, args) => {
                    if (SelectedIndex != -1)
                    {
                        ObjectGroup.RemoveObject(SelectedIndex);
                    }
                };
                menu.Append(deleteItem);
            }

            menu.AttachToWidget(this, null);
            menu.ShowAll();
            menu.PopupAtPointer(ev);
        }