From 84c83c1befe287d60aa82a2c0bf4c8e6030a4c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Thu, 1 Jan 2026 20:18:09 +0100 Subject: [PATCH] Fix --- packages/example/src/TestUi1Component.tsx | 45 ++++++++++++++++--- .../react-godot-renderer/src/Component.ts | 30 ++++++++++--- packages/react-godot-renderer/src/Renderer.ts | 2 +- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/packages/example/src/TestUi1Component.tsx b/packages/example/src/TestUi1Component.tsx index 0ce2432..fc5dc3a 100644 --- a/packages/example/src/TestUi1Component.tsx +++ b/packages/example/src/TestUi1Component.tsx @@ -1,13 +1,37 @@ -import Godot from "godot" +import Godot, { Vector2 } from "godot" +import { useEffect } from "react" import { Component } from "react-godot-renderer" -const Control = Component.make(Godot.Control) +const HFlowContainer = Component.make(Godot.HFlowContainer) const Label = Component.make(Godot.Label) +const TextEdit = Component.make(Godot.TextEdit) +const Button = Component.make(Godot.Button) export function TestUi1Component() { + const textEditRef = TextEdit.useUnsafeRef() + const buttonRef = Button.useUnsafeRef() + + useEffect(() => { + const onTextChanged = Godot.Callable.create(() => { + console.log(textEditRef.current.text) + }) + + textEditRef.current.text_changed.connect(onTextChanged) + return () => { textEditRef.current.text_changed.disconnect(onTextChanged) } + }, [textEditRef.current]) + + useEffect(() => { + const onPressed = Godot.Callable.create(() => { + console.log("Pressed!") + }) + + buttonRef.current.pressed.connect(onPressed) + return () => { buttonRef.current.pressed.disconnect(onPressed) } + }, [buttonRef.current]) + return ( - - - + + +