ComposeScreen¶
abstract class ComposeScreen(title: Component, val asynchronous: Boolean = true) : Screen, CoroutineScope
A Compose-driven Minecraft Screen base class with layer support, async recomposition, and full pointer/keyboard input dispatch.
Extend this class and call start inside your init() override:
class MyScreen : ComposeScreen(Component.literal("My Screen")) {
override fun init() {
super.init()
start {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(Component.literal("Hello!"))
}
}
}
}
Parameters¶
-
title: The screen title passed to the vanilla Screen constructor.
-
asynchronous: When
true(default), recomposition runs off the main thread and the result is joined at the start of the next frame for smooth, non-blocking updates. Set tofalseto force synchronous recomposition (simpler but may stutter).
Constructors¶
ComposeScreen¶
constructor(title: Component, asynchronous: Boolean = true)
Parameters
-
title: The screen title passed to the vanilla Screen constructor.
-
asynchronous: When
true(default), recomposition runs off the main thread and the result is joined at the start of the next frame for smooth, non-blocking updates. Set tofalseto force synchronous recomposition (simpler but may stutter).
Properties¶
asynchronous¶
val asynchronous: Boolean
Parameters
- asynchronous: When
true(default), recomposition runs off the main thread and the result is joined at the start of the next frame for smooth, non-blocking updates. Set tofalseto force synchronous recomposition (simpler but may stutter).
backgroundMusic¶
@get:
Nullable
open val backgroundMusic: Music?
coroutineContext¶
override val coroutineContext: CoroutineContext
currentFocusPath¶
@get:
Nullable
open val currentFocusPath: ComponentPath?
focused¶
@get:
Nullable
open var focused: GuiEventListener?
height¶
isDragging¶
var isDragging: Boolean
isFocused¶
isPauseScreen¶
open val isPauseScreen: Boolean
narrationMessage¶
open val narrationMessage: Component?
rectangle¶
open val rectangle: ScreenRectangle?
tabOrderGroup¶
open val tabOrderGroup: Int
title¶
open val title: Component?
width¶
Functions¶
added¶
open fun added()
afterKeyboardAction¶
open fun afterKeyboardAction()
afterMouseAction¶
open fun afterMouseAction()
afterMouseMove¶
open fun afterMouseMove()
charTyped¶
children¶
clearFocus¶
open fun clearFocus()
getChildAt¶
open fun getChildAt(mouseX: Double, mouseY: Double): Optional<GuiEventListener?>?
handleComponentClicked¶
open fun handleComponentClicked(@Nullable
style: Style?): Boolean
handleDelayedNarration¶
open fun handleDelayedNarration()
init¶
isMouseOver¶
open fun isMouseOver(mouseX: Double, mouseY: Double): Boolean
keyPressed¶
open override fun keyPressed(
keyCode: Int,
scanCode: Int,
modifiers: Int
): Boolean
keyReleased¶
open override fun keyReleased(
keyCode: Int,
scanCode: Int,
modifiers: Int
): Boolean
mouseClicked¶
open override fun mouseClicked(
mouseX: Double,
mouseY: Double,
button: Int
): Boolean
mouseDragged¶
mouseMoved¶
open override fun mouseMoved(mouseX: Double, mouseY: Double)
mouseReleased¶
open override fun mouseReleased(
mouseX: Double,
mouseY: Double,
button: Int
): Boolean
mouseScrolled¶
nextFocusPath¶
@Nullable
open fun nextFocusPath(event: FocusNavigationEvent?): ComponentPath?
onClose¶
open override fun onClose()
onFilesDrop¶
open fun onFilesDrop(packs: List<Path?>?)
removed¶
open fun removed()
render¶
renderBackground¶
open fun renderBackground(
guiGraphics: GuiGraphics?,
mouseX: Int,
mouseY: Int,
partialTick: Float
)
renderNodes¶
open fun renderNodes(
guiGraphics: GuiGraphics,
mouseX: Int,
mouseY: Int,
partialTick: Float
)
Measures and renders all active layers.
In async mode the previous recompose job is joined before rendering, then a new job is launched if there are pending frame waiters.
renderTransparentBackground¶
open fun renderTransparentBackground(guiGraphics: GuiGraphics?)
renderWithTooltip¶
fun renderWithTooltip(
guiGraphics: GuiGraphics?,
mouseX: Int,
mouseY: Int,
partialTick: Float
)
resize¶
setTooltipForNextRenderPass¶
open fun setTooltipForNextRenderPass(tooltip: List<FormattedCharSequence?>?)
open fun setTooltipForNextRenderPass(tooltip: Component?)
open fun setTooltipForNextRenderPass(
tooltip: List<FormattedCharSequence?>?,
positioner: ClientTooltipPositioner?,
override: Boolean
)
open fun setTooltipForNextRenderPass(
tooltip: Tooltip?,
positioner: ClientTooltipPositioner?,
override: Boolean
)
shouldCloseOnEsc¶
open fun shouldCloseOnEsc(): Boolean
tick¶
open fun tick()
triggerImmediateNarration¶
open fun triggerImmediateNarration(onlyNarrateNew: Boolean)
updateNarratorStatus¶
open fun updateNarratorStatus(narratorEnabled: Boolean)