private void RemoveComboBox() { if (this.comboBox == null) { return; } UnhookSelectionChangeAndClearItems(); this.comboBox.RemoveFromSuperview(); this.comboBox.Dispose(); this.comboBox = null; }
private void RequireComboBox() { if (this.comboBox != null) { return; } RemovePopup(); this.comboBox = new FocusableComboBox { AllowsExpansionToolTips = true, BackgroundColor = NSColor.Clear, Cell = { LineBreakMode = NSLineBreakMode.TruncatingTail, UsesSingleLineMode = true, }, ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView), ControlSize = NSControlSize.Small, Font = NSFont.SystemFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Small)), TranslatesAutoresizingMaskIntoConstraints = false, StringValue = String.Empty, }; this.comboBox.ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView); this.comboBox.SelectionChanged += ComboBox_SelectionChanged; AddSubview(this.comboBox); AddConstraints(new[] { NSLayoutConstraint.Create(this.comboBox, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f), NSLayoutConstraint.Create(this.comboBox, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f), NSLayoutConstraint.Create(this.comboBox, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0), }); this.firstKeyView = this.comboBox; this.lastKeyView = this.comboBox; }