Exemplo n.º 1
0
    private void createPopupMenu(IButton button)
    {
        // create menu drawable
        PopupMenuDrawable menu = new PopupMenuDrawable();

        // create menu options
        IButton option1 = menu.AddOption("Option 1");
        //option1.OnClick += (e2) => Debug.Log("menu option 1 clicked");
        IButton option2 = menu.AddOption("Option 2");

        //option2.OnClick += (e2) => Debug.Log("menu option 2 clicked");
        menu.AddSeparator();
        IButton option3 = menu.AddOption("Option 3");

        //option3.OnClick += (e2) => Debug.Log("menu option 3 clicked");

        // auto-close popup menu when any option is clicked
        menu.OnAnyOptionClicked += () => destroyPopupMenu(button);

        // hook drawable to button
        button.Drawable = menu;
    }
Exemplo n.º 2
0
        void createPopupMenu(IButton btn)
        {
            bool vesselSelected = TrackingStationUtils.getSelectedVessel() != null;
            var  menu           = new PopupMenuDrawable();

            IButton optShowParts = menu.AddOption("Show parts");

            optShowParts.Enabled  = vesselSelected;
            optShowParts.OnClick += e => showParts();

            IButton optShowInfo = menu.AddOption("Show resources");

            optShowInfo.Enabled  = vesselSelected;
            optShowInfo.OnClick += e => showInfo();

            IButton optShowOrbit = menu.AddOption("Orbit parameters");

            optShowOrbit.Enabled  = vesselSelected || (TrackingStationUtils.getSelectedPlanet() != null);
            optShowOrbit.OnClick += e => showOrbit();

            menu.OnAnyOptionClicked += () => destroyPopupMenu(btn);
            btn.Drawable             = menu;
        }