-
Notifications
You must be signed in to change notification settings - Fork 1
Canvas
A special type of container that handles all the inputs
Note
Canvas.new() is meant for people who want to create their own custom UI screens. if you want to a canvas for the screen, use GNUI.getScreenCanvas() instead.
| Type | Field | Description | |
|---|---|---|---|
boolean |
captureCursorMovement | true when the canvas should capture mouse movement, stopping the vanilla mouse movement, not the cursor itself | |
boolean |
captureInputs | true when the canvas should capture the inputs | |
boolean |
hasCustomCursorSetter | true when the setCursor is called, while false, the canvas will use the screen cursor. | |
GNUI.any? |
HoveredElement | the element the mouse is currently hovering over | |
Vector2 |
MousePosition | the position of the mouse | |
GNUI.Box? |
PassiveHoveredElement | the last hovering element. | |
GNUI.any[]? |
PressedElements | the last pressed element, used to unpress buttons that have been unhovered. | |
boolean |
reciveInputs | EventLibs whether the canvas could capture input events |
| Event | Description |
|---|---|
HOVERING_ELEMENT_CHANGED |
triggered when the hovering element changes |
INPUT |
serves as the handler for all inputs within the boundaries of the canvas. called with the first argument being an input event |
MOUSE_POSITION_CHANGED |
called when the mouse position changes |
PASSIVE_HOVERING_ELEMENT_CHANGED |
Just like the HOVERING_BOX_CHANGED, but will never be nil if there is nothing being hovered. |
UNHANDLED_INPUT |
triggers when an input is not handled by the children of the canvas. |
| Returns | Methods |
|---|---|
GNUI.Canvas |
Canvas.new(autoScreenInputs : boolean?) |
self |
Canvas:setMousePos(x : number|Vector2, y : number?) |
| Canvas:parseInputEvent(key : GNUI.keyCode, state : Event.Press.state, ctrl : boolean?, alt : boolean?, shift : boolean?, strength : number?, char : string?) | |
| Canvas:getChildFromPos(pos : Vector2) | |
| Canvas:pos2HoveringChild(pos : Vector2) | |
GNUI.Canvas |
Canvas:setHoveringChild(box : GNUI.Box) |
GNUI.any |
Canvas:getHoveredElement() |
self |
Canvas:setCaptureMouseMovement(toggle : boolean) |
self |
Canvas:setCaptureInputs(toggle : boolean) |
Creates a new canvas.
if autoScreenInputs is true, the canvas will capture input events
-
boolean?autoScreenInputs- if true, the canvas will capture input events
Sets the Mouse position relative to the canvas. meaning in canvas local space.
-
number|Vector2x -
number?y
Simulates a boolean key event into the canvas.
-
GNUI.keyCodekey -
Event.Press.statestate -
boolean?ctrl -
boolean?alt -
boolean?shift -
number?strength -
string?char
Returns the child that the point at the given position is on top of.
-
Vector2pos
Sets the child that the point at the given position is on top of.
-
Vector2pos
Sets the child being hovered.
-
GNUI.Boxbox
Returns which element the mouse cursor is on top of.
Sets whether the canvas should capture the mouse movement, making it not possible to move the mouse outside of the canvas.
-
booleantoggle
Sets whether the canvas should capture input from the user.
-
booleantoggle