Files
react-godot-renderer/packages/example/src/TestUi1Component.tsx
Julien Valverdé 54c6466127
Some checks failed
Lint / lint (push) Failing after 9s
Add Component.fromScene
2026-01-02 03:24:30 +01:00

54 lines
1.3 KiB
TypeScript

import Godot, { Vector2 } from "godot"
import { useState } from "react"
import { Component } from "react-godot-renderer"
const VFlowContainer = Component.make(Godot.VFlowContainer)
const Label = Component.make(Godot.Label)
const TextEdit = Component.make(Godot.TextEdit)
const Button = Component.make(Godot.Button)
const Test = Component.
export function TestUi1Component() {
const [text, setText] = useState("Default text")
const textEditRef = TextEdit.useRef()
Component.useSignal(textEditRef, "text_changed", function(this) {
setText(this.text)
})
const buttonRef = Button.useRef()
Component.useSignal(buttonRef, "pressed", () => {
console.log("Pressed!")
})
return (
<VFlowContainer
name="Root"
anchor_left={0}
anchor_top={0}
anchor_right={0}
anchor_bottom={0}
>
<Label
name="Label"
text="This is a label"
/>
<TextEdit
ref={textEditRef}
name="TextEdit"
text={text}
custom_minimum_size={new Vector2(200, 35)}
/>
<Button
ref={buttonRef}
name="Button"
text="Ok"
/>
</VFlowContainer>
)
}