Skip to content

OpenScreen ​

com.jsmacrosce.jsmacros.client.api.event.impl.player.EventOpenScreen

Since1.2.7Not cancellable

Fires when the client's current screen changes, including when a screen is closed. The event is dispatched after the screen field is assigned. Reassigning the current screen does not fire it. On close, both screen and screenName are null. Container screens have a separate event that can be cancelled:
EventOpenContainer.

js
JsMacros.on("OpenScreen", JavaWrapper.methodToJava(function (event) {
 if (event.screenName === null) {
   Chat.log("A screen was closed");  
 } else {
   Chat.log(`Opened ${event.screenName}`);  
 }
}))

Constructors ​

new EventOpenScreen ​

new EventOpenScreen(Screen screen)#
Captures the supplied screen and its display name when constructing the event; this does not open or close a screen. A null screen sets both event fields to null. A non-null screen must implement IScreen, or the cast fails with ClassCastException.

Parameters:

  • screen: the Minecraft screen to capture, or null when closing a screen

Fields ​

screen ​

screen: IScreenread-only#
The newly assigned screen, wrapped as an IScreen; null when a screen is closed. Its class name is available from IScreen.getScreenClassName().

screenName ​

screenName: Stringread-only#
A display name for the screen: container screens use names assigned by JsMacros, while other screens use their title or "unknown" when the title is empty. This is not a stable identifier. null when a screen is closed.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and captured screen name, in the form eventName:{"screenName": "name"}. A null screen name is formatted as the literal null; this is not JSON serialization and the screen itself is omitted.
Returns: the event name and captured screen name in diagnostic form