Interface Element

All Known Subinterfaces:
ParentElement
All Known Implementing Classes:
AbstractButtonWidget, AbstractCommandBlockScreen, AbstractFurnaceRecipeBookScreen, AbstractFurnaceScreen, AbstractInventoryScreen, AbstractParentElement, AbstractPressableButtonWidget, AccessibilityOptionsScreen, AddServerScreen, AdvancementsScreen, AlwaysSelectedEntryListWidget, AlwaysSelectedEntryListWidget.Entry, AnimatedResultButton, AnvilScreen, BackupPromptScreen, BeaconScreen, BeaconScreen.BaseButtonWidget, BeaconScreen.CancelButtonWidget, BeaconScreen.DoneButtonWidget, BeaconScreen.EffectButtonWidget, BeaconScreen.IconButtonWidget, BlastFurnaceRecipeBookScreen, BlastFurnaceScreen, BookEditScreen, BookScreen, BrewingStandScreen, ButtonListWidget, ButtonListWidget.ButtonEntry, ButtonWidget, CartographyTableScreen, ChatOptionsScreen, ChatScreen, CheckboxWidget, CommandBlockScreen, ConfirmChatLinkScreen, ConfirmScreen, ConnectScreen, ControlsListWidget, ControlsListWidget.CategoryEntry, ControlsListWidget.Entry, ControlsListWidget.KeyBindingEntry, ControlsOptionsScreen, CraftingScreen, CreateWorldScreen, CreativeInventoryScreen, CreditsScreen, CustomizeBuffetLevelScreen, CustomizeBuffetLevelScreen.BuffetBiomesListWidget, CustomizeBuffetLevelScreen.BuffetBiomesListWidget.BuffetBiomeItem, CustomizeFlatLevelScreen, CustomizeFlatLevelScreen.SuperflatLayersListWidget, CustomizeFlatLevelScreen.SuperflatLayersListWidget.SuperflatLayerItem, DatapackFailureScreen, DeathScreen, DemoScreen, DialogScreen, DirectConnectScreen, DisconnectedRealmsScreen, DisconnectedScreen, DoubleOptionSliderWidget, DownloadingTerrainScreen, EditGameRulesScreen, EditGameRulesScreen.AbstractRuleWidget, EditGameRulesScreen.BooleanRuleWidget, EditGameRulesScreen.IntRuleWidget, EditGameRulesScreen.NamedRuleWidget, EditGameRulesScreen.RuleCategoryWidget, EditGameRulesScreen.RuleListWidget, EditWorldScreen, ElementListWidget, ElementListWidget.Entry, EnchantmentScreen, EntryListWidget, EntryListWidget.Entry, FatalErrorScreen, ForgingScreen, FurnaceRecipeBookScreen, FurnaceScreen, GameMenuScreen, GameModeSelectionScreen, GameModeSelectionScreen.ButtonWidget, GameOptionsScreen, Generic3x3ContainerScreen, GenericContainerScreen, GrindstoneScreen, HandledScreen, HopperScreen, HorseScreen, InventoryScreen, JigsawBlockScreen, LanguageOptionsScreen, LanguageOptionsScreen.LanguageSelectionListWidget, LanguageOptionsScreen.LanguageSelectionListWidget.LanguageEntry, LecternScreen, LevelLoadingScreen, LockButtonWidget, LoomScreen, MerchantScreen, MerchantScreen.WidgetButtonPage, MinecartCommandBlockScreen, MouseOptionsScreen, MultiplayerScreen, MultiplayerServerListWidget, MultiplayerServerListWidget.Entry, MultiplayerServerListWidget.LanServerEntry, MultiplayerServerListWidget.ScanningEntry, MultiplayerServerListWidget.ServerEntry, MultiplayerWarningScreen, NarratorOptionsScreen, NoticeScreen, OpenToLanScreen, OptimizeWorldScreen, OptionButtonWidget, OptionSliderWidget, OptionsScreen, OutOfMemoryScreen, PackListWidget, PackListWidget.ResourcePackEntry, PackScreen, PageTurnWidget, PresetsScreen, PresetsScreen.SuperflatPresetsListWidget, PresetsScreen.SuperflatPresetsListWidget.SuperflatPresetEntry, ProgressScreen, RealmsBackupInfoScreen, RealmsBackupInfoScreen.BackupInfoList, RealmsBackupInfoScreen.BackupInfoListEntry, RealmsBackupScreen, RealmsBackupScreen.BackupObjectSelectionList, RealmsBackupScreen.BackupObjectSelectionListEntry, RealmsBridgeScreen, RealmsBrokenWorldScreen, RealmsClientOutdatedScreen, RealmsConfigureWorldScreen, RealmsConfirmScreen, RealmsCreateRealmScreen, RealmsDownloadLatestWorldScreen, RealmsGenericErrorScreen, RealmsInviteScreen, RealmsLabel, RealmsLongConfirmationScreen, RealmsLongRunningMcoTaskScreen, RealmsMainScreen, RealmsMainScreen.CloseButton, RealmsMainScreen.Entry, RealmsMainScreen.NewsButton, RealmsMainScreen.PendingInvitesButton, RealmsMainScreen.RealmSelectionList, RealmsMainScreen.RealmSelectionListEntry, RealmsMainScreen.RealmSelectionListTrialEntry, RealmsMainScreen.ShowPopupButton, RealmsNotificationsScreen, RealmsObjectSelectionList, RealmsParentalConsentScreen, RealmsPendingInvitesScreen, RealmsPendingInvitesScreen.PendingInvitationSelectionList, RealmsPendingInvitesScreen.PendingInvitationSelectionListEntry, RealmsPlayerScreen, RealmsPlayerScreen.InvitedObjectSelectionList, RealmsPlayerScreen.InvitedObjectSelectionListEntry, RealmsResetNormalWorldScreen, RealmsResetWorldScreen, RealmsResetWorldScreen.FrameButton, RealmsScreen, RealmsScreenWithCallback, RealmsSelectFileToUploadScreen, RealmsSelectFileToUploadScreen.WorldListEntry, RealmsSelectFileToUploadScreen.WorldSelectionList, RealmsSelectWorldTemplateScreen, RealmsSelectWorldTemplateScreen.WorldTemplateObjectSelectionList, RealmsSelectWorldTemplateScreen.WorldTemplateObjectSelectionListEntry, RealmsSettingsScreen, RealmsSlotOptionsScreen, RealmsSlotOptionsScreen.SettingsSlider, RealmsSubscriptionInfoScreen, RealmsTermsScreen, RealmsUploadScreen, RealmsWorldSlotButton, RecipeAlternativesWidget, RecipeAlternativesWidget.AlternativeButtonWidget, RecipeAlternativesWidget.FurnaceAlternativeButtonWidget, RecipeBookWidget, RecipeGroupButtonWidget, SaveLevelScreen, Screen, SelectWorldScreen, ShulkerBoxScreen, SignEditScreen, SkinOptionsScreen, SleepingChatScreen, SliderWidget, SmithingScreen, SmokerRecipeBookScreen, SmokerScreen, SocialInteractionsPlayerListEntry, SocialInteractionsPlayerListWidget, SocialInteractionsScreen, SoundOptionsScreen, SoundSliderWidget, StatsScreen, StatsScreen.EntityStatsListWidget, StatsScreen.EntityStatsListWidget.Entry, StatsScreen.GeneralStatsListWidget, StatsScreen.GeneralStatsListWidget.Entry, StatsScreen.ItemStatsListWidget, StatsScreen.ItemStatsListWidget.Entry, StonecutterScreen, StructureBlockScreen, TextFieldWidget, TexturedButtonWidget, TitleScreen, ToggleButtonWidget, VideoOptionsScreen, WorldListWidget, WorldListWidget.Entry

@Environment(CLIENT)
public interface Element
Base GUI interface for handling callbacks related to keyboard or mouse actions. Mouse coordinate is bounded by the size of the window in pixels.
  • 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.
    default boolean isMouseOver​(double mouseX, double mouseY)
    Checks if the mouse position is within the bound of the element.
    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 void mouseMoved​(double mouseX, double mouseY)
    Callback for when a mouse move 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.
  • Method Details

    • mouseMoved

      default void mouseMoved​(double mouseX, double mouseY)
      Callback for when a mouse move event has been captured.
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      See Also:
      Mouse.onCursorPos(long, double, double)
    • 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.
      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.
      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.
      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
    • mouseScrolled

      default boolean mouseScrolled​(double mouseX, double mouseY, double amount)
      Callback for when a mouse button scroll event has been captured.
      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.
      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.
      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.
      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)
    • 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.
      Parameters:
      lookForwards - true to cycle forwards, otherwise cycle backwards
      Returns:
      true to indicate that the event handling is successful/valid
    • isMouseOver

      default boolean isMouseOver​(double mouseX, double mouseY)
      Checks if the mouse position is within the bound of the element.
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      Returns:
      true if the mouse is within the bound of the element, otherwise false