Interface ParentElement

All Superinterfaces:
Element
All Known Implementing Classes:
AbstractCommandBlockScreen, AbstractFurnaceScreen, AbstractInventoryScreen, AbstractParentElement, AccessibilityOptionsScreen, AddServerScreen, AdvancementsScreen, AlwaysSelectedEntryListWidget, AnvilScreen, BackupPromptScreen, BeaconScreen, BlastFurnaceScreen, BookEditScreen, BookScreen, BrewingStandScreen, ButtonListWidget, ButtonListWidget.ButtonEntry, CartographyTableScreen, ChatOptionsScreen, ChatScreen, CommandBlockScreen, ConfirmChatLinkScreen, ConfirmScreen, ConnectScreen, ControlsListWidget, ControlsListWidget.CategoryEntry, ControlsListWidget.Entry, ControlsListWidget.KeyBindingEntry, ControlsOptionsScreen, CraftingScreen, CreateWorldScreen, CreativeInventoryScreen, CreditsScreen, CustomizeBuffetLevelScreen, CustomizeBuffetLevelScreen.BuffetBiomesListWidget, CustomizeFlatLevelScreen, CustomizeFlatLevelScreen.SuperflatLayersListWidget, DatapackFailureScreen, DeathScreen, DemoScreen, DialogScreen, DirectConnectScreen, DisconnectedRealmsScreen, DisconnectedScreen, DownloadingTerrainScreen, EditGameRulesScreen, EditGameRulesScreen.AbstractRuleWidget, EditGameRulesScreen.BooleanRuleWidget, EditGameRulesScreen.IntRuleWidget, EditGameRulesScreen.NamedRuleWidget, EditGameRulesScreen.RuleCategoryWidget, EditGameRulesScreen.RuleListWidget, EditWorldScreen, ElementListWidget, ElementListWidget.Entry, EnchantmentScreen, EntryListWidget, FatalErrorScreen, ForgingScreen, FurnaceScreen, GameMenuScreen, GameModeSelectionScreen, GameOptionsScreen, Generic3x3ContainerScreen, GenericContainerScreen, GrindstoneScreen, HandledScreen, HopperScreen, HorseScreen, InventoryScreen, JigsawBlockScreen, LanguageOptionsScreen, LanguageOptionsScreen.LanguageSelectionListWidget, LecternScreen, LevelLoadingScreen, LoomScreen, MerchantScreen, MinecartCommandBlockScreen, MouseOptionsScreen, MultiplayerScreen, MultiplayerServerListWidget, MultiplayerWarningScreen, NarratorOptionsScreen, NoticeScreen, OpenToLanScreen, OptimizeWorldScreen, OptionsScreen, OutOfMemoryScreen, PackListWidget, PackScreen, PresetsScreen, PresetsScreen.SuperflatPresetsListWidget, ProgressScreen, RealmsBackupInfoScreen, RealmsBackupInfoScreen.BackupInfoList, RealmsBackupScreen, RealmsBackupScreen.BackupObjectSelectionList, RealmsBridgeScreen, RealmsBrokenWorldScreen, RealmsClientOutdatedScreen, RealmsConfigureWorldScreen, RealmsConfirmScreen, RealmsCreateRealmScreen, RealmsDownloadLatestWorldScreen, RealmsGenericErrorScreen, RealmsInviteScreen, RealmsLongConfirmationScreen, RealmsLongRunningMcoTaskScreen, RealmsMainScreen, RealmsMainScreen.RealmSelectionList, RealmsNotificationsScreen, RealmsObjectSelectionList, RealmsParentalConsentScreen, RealmsPendingInvitesScreen, RealmsPendingInvitesScreen.PendingInvitationSelectionList, RealmsPlayerScreen, RealmsPlayerScreen.InvitedObjectSelectionList, RealmsResetNormalWorldScreen, RealmsResetWorldScreen, RealmsScreen, RealmsScreenWithCallback, RealmsSelectFileToUploadScreen, RealmsSelectFileToUploadScreen.WorldSelectionList, RealmsSelectWorldTemplateScreen, RealmsSelectWorldTemplateScreen.WorldTemplateObjectSelectionList, RealmsSettingsScreen, RealmsSlotOptionsScreen, RealmsSubscriptionInfoScreen, RealmsTermsScreen, RealmsUploadScreen, SaveLevelScreen, Screen, SelectWorldScreen, ShulkerBoxScreen, SignEditScreen, SkinOptionsScreen, SleepingChatScreen, SmithingScreen, SmokerScreen, SocialInteractionsPlayerListEntry, SocialInteractionsPlayerListWidget, SocialInteractionsScreen, SoundOptionsScreen, StatsScreen, StatsScreen.EntityStatsListWidget, StatsScreen.GeneralStatsListWidget, StatsScreen.ItemStatsListWidget, StonecutterScreen, StructureBlockScreen, TitleScreen, VideoOptionsScreen, WorldListWidget

@Environment(CLIENT)
public interface ParentElement
extends Element
A GUI interface which handles keyboard and mouse callbacks for child GUI elements. The implementation of a parent element can decide whether a child element receives keyboard and mouse callbacks.
  • Method Summary

    Modifier and Type Method Description
    default boolean changeFocus​(boolean lookForwards)
    Changes the focusing element by cycling to the next/previous element.
    default boolean charTyped​(char chr, int keyCode)
    Callback for when a character input has been captured.
    List<? extends Element> children()
    Gets a list of all child GUI elements.
    default void focusOn​(Element element)  
    Element getFocused()  
    default Optional<Element> hoveredElement​(double mouseX, double mouseY)  
    boolean isDragging()  
    default boolean keyPressed​(int keyCode, int scanCode, int modifiers)
    Callback for when a key down event has been captured.
    default boolean keyReleased​(int keyCode, int scanCode, int modifiers)
    Callback for when a key down event has been captured.
    default boolean mouseClicked​(double mouseX, double mouseY, int button)
    Callback for when a mouse button down event has been captured.
    default boolean mouseDragged​(double mouseX, double mouseY, int button, double deltaX, double deltaY)
    Callback for when a mouse button drag event has been captured.
    default boolean mouseReleased​(double mouseX, double mouseY, int button)
    Callback for when a mouse button release event has been captured.
    default boolean mouseScrolled​(double mouseX, double mouseY, double amount)
    Callback for when a mouse button scroll event has been captured.
    void setDragging​(boolean dragging)  
    void setFocused​(Element focused)  
    default void setInitialFocus​(Element element)  

    Methods inherited from interface net.minecraft.client.gui.Element

    isMouseOver, mouseMoved
  • Method Details

    • children

      List<? extends Element> children()
      Gets a list of all child GUI elements.
    • hoveredElement

      default Optional<Element> hoveredElement​(double mouseX, double mouseY)
    • mouseClicked

      default boolean mouseClicked​(double mouseX, double mouseY, int button)
      Callback for when a mouse button down event has been captured. The button number is identified by the constants in GLFW class.
      Specified by:
      mouseClicked in interface Element
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseButton(long, int, int, int), GLFW.GLFW_MOUSE_BUTTON_1
    • mouseReleased

      default boolean mouseReleased​(double mouseX, double mouseY, int button)
      Callback for when a mouse button release event has been captured. The button number is identified by the constants in GLFW class.
      Specified by:
      mouseReleased in interface Element
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseButton(long, int, int, int), GLFW.GLFW_MOUSE_BUTTON_1
    • mouseDragged

      default boolean mouseDragged​(double mouseX, double mouseY, int button, double deltaX, double deltaY)
      Callback for when a mouse button drag event has been captured. The button number is identified by the constants in GLFW class.
      Specified by:
      mouseDragged in interface Element
      Parameters:
      mouseX - the current X coordinate of the mouse
      mouseY - the current Y coordinate of the mouse
      button - the mouse button number
      deltaX - the difference of the current X with the previous X coordinate
      deltaY - the difference of the current Y with the previous Y coordinate
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onCursorPos(long, double, double), GLFW.GLFW_MOUSE_BUTTON_1
    • isDragging

      boolean isDragging()
    • setDragging

      void setDragging​(boolean dragging)
    • mouseScrolled

      default boolean mouseScrolled​(double mouseX, double mouseY, double amount)
      Callback for when a mouse button scroll event has been captured.
      Specified by:
      mouseScrolled in interface Element
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      amount - value is > 1 if scrolled down, < 1 if scrolled up
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseScroll(long, double, double)
    • keyPressed

      default boolean keyPressed​(int keyCode, int scanCode, int modifiers)
      Callback for when a key down event has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      keyPressed in interface Element
      Parameters:
      keyCode - the named key code of the event as described in the GLFW class
      scanCode - the unique/platform-specific scan code of the keyboard input
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see {@linkplain https://www.glfw.org/docs/3.3/group__mods.html GLFW Modifier key flags})
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onKey(long, int, int, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • keyReleased

      default boolean keyReleased​(int keyCode, int scanCode, int modifiers)
      Callback for when a key down event has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      keyReleased in interface Element
      Parameters:
      keyCode - the named key code of the event as described in the GLFW class
      scanCode - the unique/platform-specific scan code of the keyboard input
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see {@linkplain https://www.glfw.org/docs/3.3/group__mods.html GLFW Modifier key flags})
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onKey(long, int, int, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • charTyped

      default boolean charTyped​(char chr, int keyCode)
      Callback for when a character input has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      charTyped in interface Element
      Parameters:
      chr - the captured character
      keyCode - the associated key code
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onChar(long, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • getFocused

      @Nullable Element getFocused()
    • setFocused

      void setFocused​(@Nullable Element focused)
    • setInitialFocus

      default void setInitialFocus​(@Nullable Element element)
    • focusOn

      default void focusOn​(@Nullable Element element)
    • changeFocus

      default boolean changeFocus​(boolean lookForwards)
      Changes the focusing element by cycling to the next/previous element. This action is done typically when the user has pressed the 'Tab' or 'Ctrl+Tab' key.
      Specified by:
      changeFocus in interface Element
      Parameters:
      lookForwards - true to cycle forwards, otherwise cycle backwards
      Returns:
      true to indicate that the event handling is successful/valid