Interface ElementEvents
- All Known Implementing Classes:
GuiButton,GuiColourPicker,GuiColourPicker.ColourPreview,GuiColourPicker.SliderBG,GuiContextMenu,GuiDialog,GuiDVD,GuiElement,GuiEntityRenderer,GuiEventProvider,GuiItemStack,GuiList,GuiManipulable,GuiProgressIcon,GuiRectangle,GuiScrolling,GuiSlider,GuiSlots,GuiText,GuiTextField,GuiTextList,GuiTexture
Created by brandon3055 on 09/08/2023
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleandefault booleancharTyped(net.minecraft.client.input.CharacterEvent event) Override this method to implement handling for the charTyped event.default booleancharTyped(net.minecraft.client.input.CharacterEvent event, boolean consumed) Root handler for charTyped event.List<GuiElement<?>> default booleankeyPressed(net.minecraft.client.input.KeyEvent event) Override this method to implement handling for the keyPressed event.default booleankeyPressed(net.minecraft.client.input.KeyEvent event, boolean consumed) Root handler for keyPressed event.default booleankeyReleased(net.minecraft.client.input.KeyEvent event) Override this method to implement handling for the keyReleased event.default booleankeyReleased(net.minecraft.client.input.KeyEvent event, boolean consumed) Root handler for keyReleased event.default booleanmouseClicked(net.minecraft.client.input.MouseButtonEvent event) Override this method to implement handling for the mouseClicked event.default booleanmouseClicked(net.minecraft.client.input.MouseButtonEvent event, boolean consumed) Root handler for mouseClick event.default voidmouseMoved(double mouseX, double mouseY) Called whenever the cursor position changes.default booleanmouseReleased(net.minecraft.client.input.MouseButtonEvent event) Override this method to implement handling for the mouseReleased event.default booleanmouseReleased(net.minecraft.client.input.MouseButtonEvent event, boolean consumed) Root handler for mouseReleased event.default booleanmouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) Override this method to implement handling for the mouseScrolled event.default booleanmouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY, boolean consumed) Root handler for mouseScrolled event.
-
Method Details
-
getChildren
List<GuiElement<?>> getChildren()- Returns:
- An unmodifiable list of all assigned child elements assigned to this parent. The list should be sorted in the order they were added.
-
mouseMoved
default void mouseMoved(double mouseX, double mouseY) Called whenever the cursor position changes. Vanillas mouseDragged is not passed through because it is redundant. All mouse drag functionality can be archived using available events.- Parameters:
mouseX- new mouse X positionmouseY- new mouse Y position
-
mouseClicked
default boolean mouseClicked(net.minecraft.client.input.MouseButtonEvent event) Override this method to implement handling for the mouseClicked event. This event propagates through the entire gui element stack from top to bottom, If eny element consumes the event it will not propagate any further. For rare cases where you need to receive this even if it has been consumed, you can overridemouseClicked(MouseButtonEvent, boolean)Note: You do not need to call super when overriding this interface method.
- Parameters:
event- The mouse button event. Position, Key, and modifiers.- Returns:
- true to consume event.
-
mouseClicked
default boolean mouseClicked(net.minecraft.client.input.MouseButtonEvent event, boolean consumed) Root handler for mouseClick event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of mouseClick handling should be implemented viamouseClicked(MouseButtonEvent)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
event- The mouse button event. Position, Key, and modifiers.consumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
mouseReleased
default boolean mouseReleased(net.minecraft.client.input.MouseButtonEvent event) Override this method to implement handling for the mouseReleased event. This event propagates through the entire gui element stack from top to bottom, If eny element consumes the event it will not propagate any further. For rare cases where you need to receive this even if it has been consumed, you can overridemouseReleased(MouseButtonEvent, boolean)Note: You do not need to call super when overriding this interface method.
- Parameters:
event- The mouse button event. Position, Key, and modifiers.- Returns:
- true to consume event.
-
mouseReleased
default boolean mouseReleased(net.minecraft.client.input.MouseButtonEvent event, boolean consumed) Root handler for mouseReleased event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of mouseReleased handling should be implemented viamouseReleased(MouseButtonEvent)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
event- The mouse button event. Position, Key, and modifiers.consumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
mouseScrolled
default boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) Override this method to implement handling for the mouseScrolled event. This event propagates through the entire gui element stack from top to bottom, If eny element consumes the event it will not propagate any further. For rare cases where you need to receive this even if it has been consumed, you can overridemouseScrolled(double, double, double, double, boolean)Note: You do not need to call super when overriding this interface method.
- Parameters:
mouseX- Mouse X positionmouseY- Mouse Y positionscrollX- Scroll direction and amountscrollY- Scroll direction and amount- Returns:
- true to consume event.
-
mouseScrolled
default boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY, boolean consumed) Root handler for mouseScrolled event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of mouseScrolled handling should be implemented viamouseScrolled(double, double, double, double)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
mouseX- Mouse X positionmouseY- Mouse Y positionscrollX- Scroll direction and amountscrollY- Scroll direction and amountconsumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
blockMouseEvents
default boolean blockMouseEvents()- Returns:
- True to prevent mouse events from being passed to elements bellow this element.
-
keyPressed
default boolean keyPressed(net.minecraft.client.input.KeyEvent event) Override this method to implement handling for the keyPressed event. This event propagates through the entire gui element stack from top to bottom, If eny element consumes the event it will not propagate any further. For rare cases where you need to receive this even if it has been consumed, you can overridekeyPressed(KeyEvent, boolean)Note: You do not need to call super when overriding this interface method.
- Parameters:
event- The key event. Key, scancode, and modifiers.- Returns:
- true to consume event.
-
keyPressed
default boolean keyPressed(net.minecraft.client.input.KeyEvent event, boolean consumed) Root handler for keyPressed event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of keyPressed handling should be implemented viakeyPressed(KeyEvent)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
event- The key event. Key, scancode, and modifiers.consumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
keyReleased
default boolean keyReleased(net.minecraft.client.input.KeyEvent event) Override this method to implement handling for the keyReleased event. This event propagates through the entire gui element stack from top to bottom, If eny element consumes the event it will not propagate any further. For rare cases where you need to receive this even if it has been consumed, you can overridekeyReleased(KeyEvent, boolean)Note: You do not need to call super when overriding this interface method.
- Parameters:
event- The key event. Key, scancode, and modifiers.- Returns:
- true to consume event.
-
keyReleased
default boolean keyReleased(net.minecraft.client.input.KeyEvent event, boolean consumed) Root handler for keyReleased event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of keyReleased handling should be implemented viakeyReleased(KeyEvent)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
event- The key event. Key, scancode, and modifiers.consumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
charTyped
default boolean charTyped(net.minecraft.client.input.CharacterEvent event) Override this method to implement handling for the charTyped event. This event propagates through the entire gui element stack from top to bottom, If eny element consumes the event it will not propagate any further. For rare cases where you need to receive this even if it has been consumed, you can overridecharTyped(CharacterEvent, boolean)Note: You do not need to call super when overriding this interface method.
- Parameters:
event- The character event, codepoint and modifiers.- Returns:
- true to consume event.
-
charTyped
default boolean charTyped(net.minecraft.client.input.CharacterEvent event, boolean consumed) Root handler for charTyped event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of charTyped handling should be implemented viacharTyped(CharacterEvent)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
event- The character event, codepoint and modifiers.consumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-