A key-binding row: label left, binding box right showing the current key. Clicking the box enters listening mode (UIFocus.typing gates the host's keybinds automatically); the next key pressed becomes the binding and fires onChange(keyCode). Escape cancels; with allowClear on, Backspace/Delete clears the binding (fires onChange(-1)) — disable allowClear to make those keys bindable. Works on mobile only with a hardware keyboard attached; desktop-oriented.

Static methods

statickeyName(code:Int):String

A short display name for a key code (letters, digits, numpad, F-keys, navigation and common punctuation; unknown codes render as #<code>).

Parameters:

code

the platform key code

Returns:

the display name

Constructor

@:value({ keyCode : -1 })new(label:String, width:Float, keyCode:Int = -1, ?onChange:Int ‑> Void)

Parameters:

label

the row text on the left

width

layout width (the binding box sits at the right edge)

keyCode

the initial binding (-1 = unbound)

onChange

fired with the new key code on rebind/clear

Variables

@:value(true)allowClear:Bool = true

Backspace/Delete clear the binding while listening (turn off to bind them).

boxWidth:Float

Width of the binding box on the right.

@:value("")fallback:String = ""

@:value(12)fontSize:Int = 12

@:value(null)key:String = null

@:value(-1)read onlykeyCode:Int = -1

The bound key code, or -1 when unbound.

label:String

@:value(null)filter:(keyCode:Int) ‑> Bool = null

Optional code filter; return false to reject a key while listening.

@:value(null)onChange:Int ‑> Void = null

Fired with the new key code (-1 = cleared).

Methods

localize(key:String, fallback:String):Void

Switches the label to a localized string.

Parameters:

key

the translation key

fallback

the source-language text

onKeyDown(keyCode:Int, charCode:Int, ctrl:Bool, shift:Bool, alt:Bool):Bool

setBinding(code:Int):Void

Programmatically sets the binding without firing onChange.

Parameters:

code

the key code (-1 = unbound)

Inherited Variables

Defined by UIComponent

@:value(true)enabled:Bool = true

Disabled widgets ignore the pointer and typically render dimmed.

@:value(0)read onlyh:Float = 0

Layout height in UI units.

@:value(MouseCursor.BUTTON)hoverCursor:MouseCursor = MouseCursor.BUTTON

Native cursor while hovering (interactive widgets; null keeps the arrow).

@:value(false)read onlyhovered:Bool = false

true while the cursor is over this widget.

@:value(null)onClick:() ‑> Void = null

Fired on a completed click (press + release on this widget).

@:value(null)onHover:() ‑> Void = null

Fired when the cursor first enters this widget (hover-driven descriptions/previews).

@:value(null)onRightClick:() ‑> Void = null

Fired on a right mouse press over this widget (context menus).

@:value(false)read onlypressed:Bool = false

true while a press that started here is held.

@:value(null)tooltip:String = null

Optional tooltip text (already-localized or a fixed string).

@:value(null)tooltipShortcut:String = null

Optional right-aligned shortcut hint rendered in the tooltip.

@:value(0)read onlyw:Float = 0

Layout width in UI units (independent of DisplayObject's content-derived width).

Inherited Methods

Defined by UIComponent

invalidate():Void

Schedules a repaint for the next frame (cheap; deduplicated).

resize(width:Float, height:Float):Void

Sets the layout size and repaints when it changed.

Parameters:

width

the new layout width in UI units

height

the new layout height in UI units