A drop-down list: a box that shows the item chosen, and the list of items that opens under it when the box is clicked. Choosing an item in the list, with the mouse or the keyboard, changes SelectedIndex and raises SelectedIndexChanged.

The open list is drawn over every other user interface object, and while it is open it has the mouse to itself: a click on an item chooses it, and a click anywhere else in the view closes the list and goes no further. The mouse wheel scrolls a list longer than MaximumVisibleItems.

Once the drop-down has keyboard focus, Up and Down, Home and End move through the items, Space or Enter opens the list and chooses from it, Escape closes it and a letter goes to the next item that starts with it.

The box shows the selected item, or PlaceholderText when nothing is selected. Text is not used.

Constructors

UserInterfaceDropDown

#Since v9.0
public UserInterfaceDropDown()

UserInterfaceDropDown

#Since v9.0
public UserInterfaceDropDown(IEnumerable<string> items)
items (IEnumerable<string>)

Properties

BackgroundColor

public Color BackgroundColor { get; set; }
Color the control is filled with: the face of a button, the track of a slider, the box of a check box or radio button, the field of a text box, the whole rectangle of a label, icon or grid. Color.Empty, the default, means the control chooses the color for the theme that is in use and follows the theme when it changes. Labels and icons draw no background when this is Color.Empty. A grid fills with the theme's panel color when it is a top level control, and draws no background when it is inside another control. UserInterfaceGrid.BackgroundOpacity makes the theme color see through, or turns the background off at 0.
inherited fromUserInterfaceControl

BoundToActiveView

public bool BoundToActiveView { get; set; }
inherited fromUserInterfaceObjectBase

HasKeyboardFocus

public bool HasKeyboardFocus { get; }
Does this object have keyboard focus? An object with keyboard focus gets first refusal on what is typed in a viewport; what it does not use carries on to the command line as usual.
inherited fromUserInterfaceObjectBase

HorizontalAlignment

public ControlHorizontalAlignment HorizontalAlignment { get; set; }
inherited fromUserInterfaceControl

IsListOpen

#Since v9.0
public bool IsListOpen { get; set; }
Is the list open? Setting it opens the list in the view the drop-down was last drawn in, or closes it without changing the selection. Only one list is open at a time, and a drop-down that has not been added to a document has none to open.

ItemCount

#Since v9.0
public int ItemCount { get; }

Items

#Since v9.0
public IReadOnlyList<string> Items { get; }
The items in the list, in the order they are shown

Location

public PointF Location { get; set; }
inherited fromUserInterfaceControl

MaximumVisibleItems

#Since v9.0
public int MaximumVisibleItems { get; set; }
Most items the open list shows at once; a longer list scrolls. The default is 10. The list also shrinks to what fits in the view.

PlaceholderText

#Since v9.0
public string PlaceholderText { get; set; }
Text drawn, dimmed, in the box when nothing is selected

SelectedIndex

#Since v9.0
public int SelectedIndex { get; set; }
Index of the item chosen, -1 when nothing is. Setting it does not raise SelectedIndexChanged; that is only for a choice the user made. An index out of range selects nothing.

SelectedItem

#Since v9.0
public string SelectedItem { get; }
Text of the item chosen, null when nothing is

Size

public SizeF Size { get; set; }
inherited fromUserInterfaceControl

Text

public virtual string Text { get; set; }
inherited fromUserInterfaceControl

TextColor

public Color TextColor { get; set; }
Color used to draw the text. Color.Empty, the default, means use the standard text color for the theme that is in use.
inherited fromUserInterfaceControl

TextHeight

public float TextHeight { get; set; }
Height of the text in logical pixels. A value of 0, the default, means use the standard control font height. Controls that draw no text ignore this setting.
inherited fromUserInterfaceControl

TextHorizontalAlignment

public ControlHorizontalAlignment TextHorizontalAlignment { get; set; }
Where the text sits inside the control's rectangle. This is not the same as HorizontalAlignment, which is where the control sits inside its parent.
inherited fromUserInterfaceControl

TextVerticalAlignment

public ControlVerticalAlignment TextVerticalAlignment { get; set; }
Where the text sits inside the control's rectangle. This is not the same as VerticalAlignment, which is where the control sits inside its parent.
inherited fromUserInterfaceControl

Tooltip

public string Tooltip { get; set; }
Text shown in a tooltip when the mouse rests over this object. Null or an empty string means no tooltip, which is what an object starts with. One tooltip is on screen at a time; whichever object the mouse is over owns it.
inherited fromUserInterfaceObjectBase

TrackingPoint

public Point3d? TrackingPoint { get; set; }
3d location that control "sticks" to if not null
inherited fromUserInterfaceControl

VerticalAlignment

public ControlVerticalAlignment VerticalAlignment { get; set; }
inherited fromUserInterfaceControl

Visible

public bool Visible { get; set; }
Is the user interface object visible? Objects that are not visible will not be drawn and will not receive mouse events
inherited fromUserInterfaceObjectBase

Methods

AddItem

#Since v9.0
public int AddItem(string text)
Adds an item at the end of the list
text (string)
The index the item went in at

ClearItems

#Since v9.0
public void ClearItems()
Empties the list, which leaves nothing selected

ComputedRectangle

public RectangleF ComputedRectangle(RhinoView view, bool logicalPixels)
inherited fromUserInterfaceControl
view (RhinoView)
logicalPixels (bool)

InsertItem

#Since v9.0
public void InsertItem(int index, string text)
Puts an item in at index, moving the items from there on along. The same item stays selected.
index (int)
text (string)

IsMouseOver

protected virtual bool IsMouseOver(MouseState mouse)
Called to test if the mouse is actively over this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)
Return true if the mouse is over this object

IsRegistered

public bool IsRegistered()
Is this user interface object active
inherited fromUserInterfaceObjectBase

OnDraw

protected virtual void OnDraw(DrawEventArgs args)
All user interface objects are drawn and can customize their look with the OnDraw function
inherited fromUserInterfaceObjectBase
args (DrawEventArgs)

OnMouseClick

protected virtual void OnMouseClick(MouseState mouse)
Called during a mouse click event on this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)

OnMouseDoubleClick

protected virtual void OnMouseDoubleClick(MouseState mouse)
Called during a mouse double click event on this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)

OnMouseDown

protected virtual void OnMouseDown(MouseState mouse)
Called when the mouse goes down on this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)Current mouse state when this event occurs

OnMouseEnter

protected virtual void OnMouseEnter(MouseState mouse)
Called when the mouse goes over this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)

OnMouseLeave

protected virtual void OnMouseLeave(MouseState mouse)
Called when the mouse leaves this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)

OnMouseMove

protected virtual void OnMouseMove(MouseState mouse)
Called when the mouse is moved
inherited fromUserInterfaceObjectBase
mouse (MouseState)

OnMouseUp

protected virtual void OnMouseUp(MouseState mouse)
Called when the mouse is released on this object
inherited fromUserInterfaceObjectBase
mouse (MouseState)

OnRunCommand

protected virtual Result OnRunCommand(RhinoDoc doc, RunMode mode, MouseState mouse)
Called after the above RunCommand function is called. This will be executing while inside of a Rhino command.
inherited fromUserInterfaceObjectBase
doc (RhinoDoc)Document that the command is running in
mode (RunMode)Interactive or scripted mode
mouse (MouseState)Mouse state that was passed to RunCommand
Result of the command. The default implementation returns Success

OnSelectedIndexChanged

#Since v9.0
protected virtual void OnSelectedIndexChanged()
Called after the user chose a different item, from the list or with the keys. The default implementation raises the SelectedIndexChanged event.

RegisterForAllDocuments

public bool RegisterForAllDocuments()
Make this object visible for all documents. Typically you will only have user interface objects work with single documents. For that case, call doc.ViewUserInterface.Add
inherited fromUserInterfaceObjectBase

RemoveItemAt

#Since v9.0
public void RemoveItemAt(int index)
Takes the item at index out of the list. The same item stays selected; taking out the selected item leaves nothing selected.
index (int)

RunCommand

public void RunCommand(MouseState mouse)
Call RunCommand to have the virtual OnRunCommand function executed in the scope of a Rhino command. If you are modifying the document from one of the mouse functions on this object, this is the best approach to do so since changes made inside of a command are recorded for undo.
inherited fromUserInterfaceObjectBase
mouse (MouseState)Current mouse state. This is handed back to OnRunCommand

SetItem

#Since v9.0
public void SetItem(int index, string text)
Changes the text of the item at index
index (int)
text (string)

SetSvg

public void SetSvg(string svg)
inherited fromUserInterfaceControl
svg (string)

Unregister

public void Unregister()
Unregister this object
inherited fromUserInterfaceObjectBase

Events

SelectedIndexChanged

#Since v9.0
public event EventHandler SelectedIndexChanged
Raised after the user chose a different item, from the list or with the keys