コード例 #1
0
        private void RemovePopup()
        {
            if (this.popupButton == null)
            {
                return;
            }

            this.popupButton.Activated -= PopupButton_Activated;
            this.popupButton.RemoveFromSuperview();
            this.popupButton.Dispose();
            this.popupButton = null;

            this.popupButtonList.RemoveAllItems();
            this.popupButtonList.Dispose();
            this.popupButtonList = null;
        }
コード例 #2
0
        private void RequirePopup()
        {
            if (this.popupButton != null)
            {
                return;
            }

            RemoveComboBox();

            this.popupButton = new FocusablePopUpButton {
                AllowsExpansionToolTips = true,
                Cell =
                {
                    LineBreakMode      = NSLineBreakMode.TruncatingTail,
                    UsesSingleLineMode = true,
                },
                ControlSize = NSControlSize.Small,
                Font        = NSFont.SystemFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Small)),
                TranslatesAutoresizingMaskIntoConstraints = false,
                StringValue    = String.Empty,
                ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView)
            };
            this.popupButton.ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView);
            this.popupButtonList            = new NSMenu();
            this.popupButton.Menu           = this.popupButtonList;
            this.popupButton.Activated     += PopupButton_Activated;

            AddSubview(this.popupButton);

            AddConstraints(new[] {
                NSLayoutConstraint.Create(this.popupButton, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
                NSLayoutConstraint.Create(this.popupButton, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f),
                NSLayoutConstraint.Create(this.popupButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0),
            });

            this.firstKeyView = this.popupButton;
            this.lastKeyView  = this.popupButton;
        }