Skip to content

LayoutNodeFocusAdapter

class LayoutNodeFocusAdapter(val node: LayoutNode) : GuiEventListener

Bridges one FocusableModifier-carrying LayoutNode into vanilla Minecraft's GuiEventListener focus graph, so vanilla's Tab/Shift-Tab and arrow-key navigation - and anything else that walks GuiEventListener, e.g. Controlify's controller navigation - reaches Compose content the same way it reaches an ordinary AbstractWidget.

ComposeScreen/ComposeContainerScreen rebuild a fresh list of adapters on every children() call, since the LayoutNode tree can change between frames. Vanilla's own ContainerEventHandler.handleTabNavigation looks up the previously-focused GuiEventListener by indexOf in that freshly rebuilt list, so equals/hashCode are keyed on the wrapped node's identity rather than the adapter's - two adapters wrapping the same node must compare equal across separate children() calls, or Tab would never be able to tell "the currently focused thing" apart from "a brand new list entry" and always restart from the beginning.

Constructors

LayoutNodeFocusAdapter

constructor(node: LayoutNode)

Properties

currentFocusPath

@get:



Nullable



open val currentFocusPath: ComponentPath?

isFocused

open override fun isFocused(): Boolean
open override var isFocused: Boolean

node

rectangle

open override val rectangle: ScreenRectangle

tabOrderGroup

open val tabOrderGroup: Int

Functions

charTyped

open override fun charTyped(codePoint: Char, modifiers: Int): Boolean

Forwards to node's own OnCharTypedModifier chain - the same one the broadcast char dispatch uses.

equals

open operator override fun equals(other: Any?): Boolean

getRectangle

open override fun getRectangle(): ScreenRectangle

hashCode

open override fun hashCode(): Int

isMouseOver

open fun isMouseOver(mouseX: Double, mouseY: Double): Boolean

keyPressed

open override fun keyPressed(
    keyCode: Int, 
    scanCode: Int, 
    modifiers: Int
): Boolean

Forwards to node's own OnKeyEventModifier chain - the same one the broadcast key dispatch uses.

keyReleased

open fun keyReleased(
    keyCode: Int, 
    scanCode: Int, 
    modifiers: Int
): Boolean

mouseClicked

open fun mouseClicked(
    mouseX: Double, 
    mouseY: Double, 
    button: Int
): Boolean

mouseDragged

open fun mouseDragged(
    mouseX: Double, 
    mouseY: Double, 
    button: Int, 
    dragX: Double, 
    dragY: Double
): Boolean

mouseMoved

open fun mouseMoved(mouseX: Double, mouseY: Double)

mouseReleased

open fun mouseReleased(
    mouseX: Double, 
    mouseY: Double, 
    button: Int
): Boolean

mouseScrolled

open fun mouseScrolled(
    mouseX: Double, 
    mouseY: Double, 
    scrollX: Double, 
    scrollY: Double
): Boolean

nextFocusPath

open override fun nextFocusPath(event: FocusNavigationEvent): ComponentPath?

setFocused

open override fun setFocused(focused: Boolean)