Options
All
  • Public
  • Public/Protected
  • All
Menu

Module uicontrols

Functions that create user interface controls that can be organized into layouts with the uilayout library and bound to game components with uibindings.

Include this library by adding useLibrary("uicontrols") (or ui) to your script. See the plug-in authoring kit for examples that use this library.

Index

Functions

autocompletionField

  • Create a text field with a drop-down autocompletion list.

    Parameters

    • items: string[]

      an array of items that the field will use to offer autocompletion choices

    • Optional sorted: boolean

      an optional flag indicating that the item list should be sorted, which allows faster autocompletion

    Returns JavaObject<"swing.JComboBox">

    an editable combo box with autocompletion support

button

  • Returns a new button.

    Parameters

    • Optional label: string

      an optional text label for the button

    • Optional icon: JavaObject<"swing.Icon">

      an optional icon for the button

    • Optional listener: CallableFunction

      an optional function that will be called when the button is pressed

    Returns JavaObject<"swing.JButton">

    the new button

buttonGroup

  • Returns a new button group for a group of buttons. Button groups are used to link together a set of related toggle buttons or radio buttons so that only one button in the group can be selected at a time. The optional settingValues argument is a list of setting values to associate with the buttons in the group. If it is supplied, then the returned button group can be bound using a Bindings instance, and selecting a button in the group will change the bound setting to the corresponding element in settingValues. If the settingValues argument is not supplied, then a plain button group that does not support binding is returned.

    Parameters

    Returns JavaObject<"swing.ButtonGroup">

    the button group

checkBox

  • Returns a new check box.

    Parameters

    • Optional label: string

      an optional text label for the button

    • Optional selected: boolean

      if true, the box is initially checked

    • Optional listener: CallableFunction

      an optional function that will be called when the box is checked or unchecked

    Returns JavaObject<"swing.JCheckBox">

    the new check box

codeArea

  • codeArea(text?: string, preferredWidth?: number, preferredHeight?: number): CodeEditor
  • Returns a new script editor control.

    Parameters

    • Optional text: string

      optional initial text for the code area

    • Optional preferredWidth: number

      an optional preferred pixel width for the control (default is 400)

    • Optional preferredHeight: number

      an optional preferred pixel height for the control (default is 300)

    Returns CodeEditor

comboBox

  • Returns a new combo box containing the given list of items.

    Parameters

    • Optional items: any[]

      an array of items for the user to choose from (default is an empty list)

    • Optional listener: CallableFunction

      an optional listener that is called when the selected item changes

    Returns JavaObject<"swing.JComboBox">

    the new combo box

cycleButton

  • Returns a new cycle button that will rotate through the specified labels when pressed. Cycle buttons are suitable for use with a very small number of options, preferably 2, when the user can easily guess what the other options in the set are. An example of this is a button to select a gender. If the optional setting values are provided, they will be used to map the selected label to and from a setting value when the control is bound using a Bindings instance.

    Parameters

    • labels: string[]

      an array of labels for the button to rotate through when pressed

    • Optional settingValues: string[]

      an optional array of setting values (strings) to map the labels to

    Returns JavaObject<"ca.cgjennings.ui.JCycleButton">

    the cycle button

helpButton

  • Returns a new help button. A help button displays as a small purple help icon. When clicked on, it opens a help page in the user's default browser. If the URL appears to be a Web page, that Web page is opened. Otherwise, it opens the documentation page with the same file name.

    Parameters

    • url: string

      the URL or page file name to open when the button is clicked

    Returns JavaObject<"ca.cgjennings.ui.JHelpButton">

    the new help button

hyperlink

  • Returns a new hyperlink label, a label with underlined blue text that opens a URL in the user's default browser when clicked.

    Parameters

    • text: string | null

      an optional text label (default is to use url)

    • url: string

      the URL to visit when the label is clicked

    Returns JavaObject<"ca.cgjennings.ui.JLinkLabel">

    the new hyperlink label

label

  • Returns a new label.

    Parameters

    • Optional text: string

      initial label text (default is an empty string)

    • Optional labelFor: JavaObject<"java.awt.Component">

      the control that this label is a label for; determines which control to activate if the label has a mnemonic key set

    Returns JavaObject<"swing.JLabel">

    the new label

listControl

  • Returns a new list box containing the given list of items.

    Parameters

    • Optional items: string[]

      an array of items for the user to choose from (default is an empty list)

    • Optional listener: CallableFunction

      an optional listener that is called when the selected item changes

    • Optional scroll: boolean

      if true, a scroll pane will be wrapped around the list control and returned

    Returns JavaObject<"swing.JList"> | JavaObject<"swing.JScrollPane">

    the list, or the scroll pane that wraps it

noMarkup

  • Calling this function on a UI control will prevent that control from becoming a target for the Markup menu or displaying a context bar. The function returns the same control that is passed to it, so it can be wrapped transparently around the function used to create the control: let field = noMarkup(textField("42", 4));.

    control : the UI control to prevent from accepting markup

    Parameters

    Returns JavaObject<"swing.JComponent">

noteLabel

  • Returns a new note label, a label with a smaller than usual font size that can be used to add remarks, tips, or other secondary information.

    Parameters

    • Optional text: string

      initial label text (default is an empty string)

    Returns JavaObject<"swing.JLabel">

    the new label

portraitPanel

  • Creates a new portrait panel that allows the user to choose and adjust a portrait image. For DIY components, note that if you use the standard simple method of adding a portrait, the portrait panel will be created and linked up for you. If you use the custom portrait handling option, you'll need to create and add portrait panels yourself.

    Parameters

    • gc: JavaObject<"arkham.component.PortraitProvider">

      the PortraitProvider (usually a game component, such as a DIY) that provides the portrait model

    • Optional portraitIndex: number

      the index of the portrait controlled by this panel (for components with multiple portraits; default is 0)

    • Optional title: string

      an optional title for the panel; if not specified, a localized default title will be provided

    Returns JavaObject<"arkham.PortraitPanel">

    the portrait editing panel

radioButton

  • Returns a new radio button. Radio buttons are use to represent a group of options of which only one can be selected at a time. To define the members of such a group, first create the buttons and then call buttonGroup(arrayOfRadioButtonsToGroup) to create the group.

    Parameters

    • Optional label: string

      an optional text label for the button

    • Optional selected: boolean

      if true, the button will initially be selected (default is false)

    • Optional listener: CallableFunction

      an optional function that will be called when the button is pressed

    Returns JavaObject<"swing.JRadioButton">

    the new button

repeaterButton

  • Returns a new button that continues to notify listeners at intervals as long as it is pressed down. The rate of listener notifications increases the longer the button is held down.

    Parameters

    • Optional label: string

      an optional text label for the button

    • Optional icon: JavaObject<"swing.Icon">

      an optional icon for the button

    • Optional listener: CallableFunction

      an optional function that will be called when the button is pressed

    Returns JavaObject<"swing.JButton">

    the new button

separator

  • Returns a new separator, a dividing line that can be used to visually separate groups of controls.

    Parameters

    • Optional vertical: boolean

      if true, the separator has a vertical orientation (the default is horizontal)

    Returns JavaObject<"swing.JSeparator">

    the new separator

slider

  • Creates a new slider control that can be set to one of a range of integer values between min and max, inclusive. If valueLabelPairs is supplied, it must be an array where the even indices are slider positions and the odd indices are labels. The control will display the requested labels at the indicated positions. For example: [1, "Low", 6, "Medium", 10, "High"] would display the labels Low, Medium, and High at positions 1, 6, and 10 on the slider, respectively.

    Parameters

    • Optional min: number

      the minimum value that the slider will allow (default is 1)

    • Optional max: number

      the maximum value that the slider will allow (default is 10)

    • Optional initial: number

      the initial value of the slider (default is min)

    • Optional valueLabelPairs: []

      an array of alternating numbers and strings; each number is a value to be labelled, while the corresponding string is the label text to display

    • Optional listener: JavaObject<"swing.event.ChangeListener">

      an optional change listener that will be called when the value changes

    Returns JavaObject<"swing.JSlider">

    the new slider

spinner

  • Creates a new spinner control that can be set to one of a range of integer values between min and max, inclusive. Each click of a spinner arrow will add or subtract stepSize from the current value.

    Parameters

    • Optional min: number

      the minimum value that the spinner will allow (default is 1)

    • Optional max: number

      the maximum value that the spinner will allow (default is 10)

    • Optional stepSize: number

      the amount added to the current value by clicking an arrow button (default is 1)

    • Optional initialValue: number

      the initial value stored in the spinner (default is min)

    • Optional listener: JavaObject<"swing.event.ChangeListener">

      an optional change listener that will be called when the value changes

    Returns JavaObject<"swing.JSpinner">

    the new spinner control

textArea

  • Returns a new multiline text area.

    Parameters

    • Optional text: string

      optional initial text for the text area (default is an empty string)

    • Optional rows: number

      an optional number of rows for the width of the text area

    • Optional columns: number

      an optional number of columns for the width of the field

    • Optional wrapInScrollPane: boolean

      if true, the text area will be wrapped in a scroll pane

    • Optional spellingChecked: boolean

      if true the contents will be checked for spelling if supported (default is true)

    Returns JavaObject<"swing.JTextArea"> | JavaObject<"swing.JScrollPane">

textField

  • Returns a new text field control.

    Parameters

    • Optional text: string

      optional initial text for the field (default is an empty string)

    • Optional columns: number

      an optional number of columns for the width of the field

    • Optional listener: CallableFunction

      an optional function that will be called when enter is pressed in ... the field (default is no listener)

    • Optional spellingChecked: boolean

      if true the contents will be checked for spelling if supported (default is true)

    Returns JavaObject<"swing.JTextField">

tintPanel

tipButton

  • Returns a new tip button. A tip button displays as a small information icon. When the pointer is moved over the icon or the icon is clicked, a small pop-up window displays the tip text.

    Parameters

    • text: string

      the text to display when the pointer is moved over the tip icon

    Returns JavaObject<"ca.cgjennings.ui.JTip">

    the new tip control

toggleButton

  • Returns a new toggle button.

    Parameters

    • Optional label: string

      an optional text label for the button

    • Optional icon: JavaObject<"swing.Icon">

      an optional icon for the button

    • Optional selected: boolean

      if true, the button will initially be selected (default is false)

    • Optional listener: CallableFunction

      an optional function that will be called when the button is pressed

    Returns JavaObject<"swing.JToggleButton">

    the new button