Class ComboBox

The ComboBox class is a selection widget that displays the current item, and provides a dropdown list of selectable items.

Hierarchy

Constructors

Properties

m_arrow: DownArrow
m_children: Widget[] = []
m_content: Widget
m_dom: HTMLElement
m_icon: Icon
m_items: ComboItem[] = []
m_mode: number = ...
m_parent: Widget
m_popup: Popup
m_scrollArea: ScrollArea
m_selected: ComboItem
m_text: Text
m_widget: Widget
Horizontal: 256 = 0x0100
IconMask: 240 = 0x00F0
LargeIcon: 32 = 0x0020
LargeMode: number = ...
SmallIcon: 16 = 0x0010
SmallMode: number = ...
Text: 1 = 0x0001
TextMask: 15 = 0x000F
TextMode: number = ...
ToolMode: number = ...
Vertical: 512 = 0x0200

Accessors

  • get blocked(): boolean
  • Returns true if events are blocked; otherwise returns false.

    Returns boolean

  • set blocked(blocked): void
  • If blocked is true, then events emitted by this event watcher will be blocked, meaning that emitting an event will not trigger any callback functions that are bound to it.

    Parameters

    • blocked: boolean

    Returns void

  • get children(): readonly Widget[]
  • Returns the list of children.

    Returns readonly Widget[]

  • get count(): number
  • Returns the number of items in this combobox.

    Returns number

  • set css(style): void
  • Sets the style of this widget. See also id addClass.

    Parameters

    Returns void

  • get currentText(): string
  • Returns the text of the current item in this combobox.

    Returns string

  • set currentText(text): void
  • If there is a matching text in the list, the current index is set to the corresponding index.

    Parameters

    • text: string

    Returns void

  • get direction(): Direction
  • Returns the popup direction.

    Returns Direction

  • set direction(direction): void
  • Set the popup direction to direction. If there is not enough space, it will be popped up in other directions.

    Parameters

    Returns void

  • get dom(): HTMLButtonElement
  • Returns the dom of this button.

    Returns HTMLButtonElement

  • get enabled(): boolean
  • Returns whether this widget or its parent chain is enabled or not. By default, the value of this property is true.

    Returns boolean

  • set enabled(enabled): void
  • Sets whether this widget is enabled or not. Disabling a widget implicitly disables all its children, it is not possible to explicitly enable a child widget while its parent widget remains disabled.

    Parameters

    • enabled: boolean

    Returns void

  • get height(): number
  • Returns the height of this widget.

    Returns number

  • set height(height): void
  • Sets the height of this widget to the given height.

    Parameters

    • height: number

      The unit of height is px.

    Returns void

  • get id(): string
  • Returns the id of this widget.

    Returns string

  • set id(id): void
  • Set the id of this widget to the given id. The id is utilized to set the style of the widget. See also css

    Parameters

    • id: string

    Returns void

  • get image(): string
  • Returns the image shown on this button.

    Returns string

  • set image(icon): void
  • Sets the image shown on this button to the given icon.

    Parameters

    • icon: string

    Returns void

  • get index(): number
  • Returns the index of the current item in this combobox.

    Returns number

  • set index(index): void
  • Sets the current item corresponding to index.

    Parameters

    • index: number

    Returns void

  • get left(): number
  • Returns the left coordinate of this widget within its parent widget.

    Returns number

  • set left(left): void
  • Sets the left coordinate of this widget within its parent widget.

    Parameters

    • left: number

      The unit of left is px.

    Returns void

  • set maxMenuHeight(height): void
  • Sets the menu's maximum height to the given height.

    Parameters

    • height: number

    Returns void

  • Returns the button's associated popup menu.

    Returns Menu

  • get mode(): number
  • Returns the mode of this button, the default mode is TextMode.

    The image is shown on this button when in icon mode. The image's default size is Size(16, 16). When in large icon mode, the image's size is Size(32, 32).

    Returns number

  • set mode(mode): void
  • Sets the mode of the button to the given mode.

    Parameters

    • mode: number

    Returns void

  • get parent(): Widget
  • Returns the parent of this widget, or undefined if it does not have any parent widget.

    Returns Widget

  • set parent(parent): void
  • Sets the parent of the widget to the given parent. If the new parent widget is the old parent widget, this function does nothing.

    Parameters

    Returns void

  • get position(): Point
  • Returns the position of this widget within its parent widget.

    Returns Point

  • set position(position): void
  • Sets the position of this widget to the given position.

    Parameters

    • position: Point

      The unit of position is px.

    Returns void

  • get rect(): Rect
  • Returns the rect of this widget within the desktop.

    Returns Rect

  • get selected(): ComboItem
  • Returns the current item in this combobox. The current item can change when inserting or removing items.

    Returns ComboItem

  • set selected(selected): void
  • Sets the current item in this combobox to selected.

    Parameters

    Returns void

  • get size(): Size
  • Returns the size of this widget.

    Returns Size

  • set size(size): void
  • Sets the size of this widget to the given size. If the size is Size(0, 0) will cause the widget to not appear on screen.

    Parameters

    • size: Size

      The unit of size is px.

    Returns void

  • get style(): CSSStyleDeclaration
  • Returns the style of this widget.

    Returns CSSStyleDeclaration

  • get text(): string
  • Returns the text shown on this button.

    Returns string

  • set text(text): void
  • Sets the text shown on this button to the given text.

    Parameters

    • text: string

    Returns void

  • get toggled(): boolean
  • Returns boolean

  • set toggled(toggled): void
  • Parameters

    • toggled: boolean

    Returns void

  • get tooltip(): string
  • Returns the tooltip of this widget. When the mouse hovers over the widget for a period of time(it can be set by Tooltip::WakeUpDelay), a message will automatically pop up, and it will disappear automatically when the mouse moves away. By default, the value of this property is an empty string.

    Returns string

  • set tooltip(tooltip): void
  • Sets the tooltip of this widget to the given tooltip.

    Parameters

    • tooltip: string

    Returns void

  • get top(): number
  • Returns the top coordinate of this widget within its parent widget.

    Returns number

  • set top(top): void
  • Sets the top coordinate of this widget to the given top.

    Parameters

    • top: number

      The unit of top is px.

    Returns void

  • get visible(): boolean
  • Returns whether this widget or its parent chain is visible or not. By default, the value of this property is true.

    Returns boolean

  • set visible(visible): void
  • Sets whether this widget is visible or not. If an ancestor widget is not visible, the widget won't become visible until all its ancestors are visible.

    Parameters

    • visible: boolean

    Returns void

  • get widget(): Widget
  • Returns the popup widget of this button.

    Returns Widget

  • set widget(widget): void
  • Sets the popup widget of this button to the given widget.

    Parameters

    Returns void

  • get width(): number
  • Returns the width of this widget.

    Returns number

  • set width(width): void
  • Sets the width of this widget to the given width.

    Parameters

    • width: number

      The unit of width is px.

    Returns void

  • get sender(): EventWatcher
  • Returns the object that sent the event.

    Returns EventWatcher

Methods

  • Adds an item to this combobox with the given text, The item is appended to the list of existing items.

    Parameters

    • text: string

    Returns ComboItem

  • Adds the attribute of this widget. The attribute is utilized to set the style. See also css

    Parameters

    • attr: string

    Returns void

  • Adds the class name of this widget. The class name is utilized to set the style. See also css. All widgets with the same class name use the same style.

    Parameters

    • className: string

    Returns void

  • Returns the item that occupies the given index in the list.

    Parameters

    • index: number

    Returns ComboItem

  • Returns void

  • Adds a callback function that's going to be called when the event is emitted.

    Type Parameters

    Parameters

    • name: K
    • callback: ((...data) => void)
        • (...data): void
        • Parameters

          Returns void

    Returns void

  • Parameters

    • name: string
    • callback: ((...data) => void)
        • (...data): void
        • Parameters

          • Rest ...data: any[]

          Returns void

    Returns void

  • Clears all items in this combobox.

    Returns void

  • Clears all widgets in the list of children.

    Returns void

  • Closes this button and the popup widget.

    Returns void

  • Returns void

  • Delegates this event watcher to handle the given watcher's event named name.

    Type Parameters

    Parameters

    Returns void

  • Parameters

    Returns void

  • Destroys the widget, all the widget's children are destroyed first. The widget is destroyed when it's parent is destroyed. When the widget is destroyed, make sure to release all resources, such as timers, etc. Releases the resources in the protected function free(), and the system will call this function automatically when the parent widget or itself is destroyed. See also free.

    Returns void

  • Returns void

  • Emits an arbitrary set of arguments to the callback function which is bound to the event named name.

    Type Parameters

    Parameters

    Returns boolean

  • Parameters

    • name: string
    • Rest ...data: any[]

    Returns boolean

  • Performs the specified action for each item.

    Parameters

    • callback: ((item) => void)
        • (item): void
        • Parameters

          Returns void

    Returns void

  • Frees the resources.See also destroy.

    Returns void

  • Returns whether this widget contains the attribute.

    Parameters

    • attr: string

    Returns boolean

  • Returns whether this widget contains the class name.

    Parameters

    • className: string

    Returns boolean

  • Hides the widget and its child widgets. This function is equivalent to setting the visible property to false.

    Returns void

  • Inserts the text into this combobox at the given index.

    Parameters

    • index: number
    • text: string

    Returns ComboItem

  • Inserts the child widget at index in the list of children.

    Parameters

    Returns void

  • Raises this widget to the front of the parent widget's children. The display order of this widget is determined by the order in which they appear in the parent widget's children.

    Returns boolean

  • Removes the item from this combobox. This will update the current index if the item is removed. This function does nothing if the item is not in the list of items.

    Parameters

    Returns void

  • Removes the attribute of this widget.

    Parameters

    • attr: string

    Returns void

  • Removes the class name of this widget.

    Parameters

    • className: string

    Returns void

  • Sets whether the widget uses flex layout.

    Parameters

    Returns void

  • Shows the widget and its child widgets. This function is equivalent to setting the visible property to true.

    Returns void

  • If param attr is true, adds the attribute, otherwise removes the attribute.

    Parameters

    • attr: string
    • on: boolean

      true or false

    Returns void

  • If param on is true, adds the class name, otherwise removes the class name.

    Parameters

    • className: string
    • on: boolean

      true or false

    Returns void

  • Removes the specified watcher for the event named name.

    Type Parameters

    Parameters

    • name: K

    Returns void

  • Parameters

    • name: string

    Returns void

  • Returns void

Generated using TypeDoc