コード例 #1
0
        /// <summary>
        /// Adds the elements associated with a command to a NSPopUpButton.
        /// </summary>
        /// <param name="command">The command to associate with the elements in the popup button.</param>
        /// <param name="button">The button to which the command is to be added.</param>
        /// <param name="itemTitles">The user-visible names of the items to add to the popup button.</param>
        /// <param name="itemTags">The identifying information for the choices added to the popup button.</param>
        /// <param name="itemToolTips">Tool tips for the choices in the popup button.</param>
        /// <remarks>The NSPopUpButton presents a choice for the user to select. The same command is associated with each choice in the
        /// button. When the command is invoked, the Tag associated with the item in the popup button is part of the data used in executing the command.</remarks>
        public static void PopulatePopUpButton(this ICommand command, NSPopUpButton button, string[] itemTitles, int[] itemTags, string[] itemToolTips)
        {
            button.RemoveAllItems();
            button.AddItems(itemTitles);
            var menuItems = button.Items();

            for (int i = 0; i < menuItems.Length; ++i)
            {
                var menuItem = menuItems[i];
                menuItem.RepresentedObject = new NSObjectWrapper <ICommand>(command);
                menuItem.Tag     = itemTags[i];
                menuItem.ToolTip = itemToolTips[i];
            }
        }
コード例 #2
0
			public PopUpImp(ComboBox owner)
			{
				this.owner = owner;				

				popup = new NSPopUpButton();
				popup.BezelStyle = NSBezelStyle.Rounded;
				popup.Alignment = NSTextAlignment.Natural;
				popup.Enabled = owner.Enabled;
				popup.Font = owner.Font.ToNSFont();
				//popup.PullsDown = true;
				popup.Activated += owner.OnImpSelectedItemChanged;

				foreach (object item in owner.items)
					popup.AddItem(owner.GetItemText(item));

				if (owner.selected_index >= 0 && owner.selected_index < popup.Items().Length)
					popup.SelectItem(owner.selected_index);
			}
コード例 #3
0
		public NSView CreateView()
		{
			popup = new NSPopUpButton();
			popup.BezelStyle = NSBezelStyle.Rounded;
			popup.Alignment = NSTextAlignment.Natural;
			popup.Enabled = Enabled;
			popup.Font = Font.ToNSFont();
			//popup.PullsDown = true;
			popup.Activated += Popup_Activated;

			foreach (object item in items)
				popup.AddItem(GetItemText(item));

			if (selected_index >= 0 && selected_index < popup.Items().Length)
				popup.SelectItem(selected_index);

			return popup;
		}
コード例 #4
0
			public void SetItemTitle(int index, string title)
			{
				popup.Items()[index].Title = title;
			}