This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Godot, { Vector2 } from "godot"
|
||||
import { useEffect } from "react"
|
||||
import { useEffect, useState } from "react"
|
||||
import { Component } from "react-godot-renderer"
|
||||
|
||||
|
||||
@@ -9,12 +9,14 @@ const TextEdit = Component.make(Godot.TextEdit)
|
||||
const Button = Component.make(Godot.Button)
|
||||
|
||||
export function TestUi1Component() {
|
||||
const [text, setText] = useState("Default text")
|
||||
|
||||
const textEditRef = TextEdit.useUnsafeRef()
|
||||
const buttonRef = Button.useUnsafeRef()
|
||||
|
||||
useEffect(() => {
|
||||
const onTextChanged = Godot.Callable.create(() => {
|
||||
console.log(textEditRef.current.text)
|
||||
setText(textEditRef.current.text)
|
||||
})
|
||||
|
||||
textEditRef.current.text_changed.connect(onTextChanged)
|
||||
@@ -46,7 +48,7 @@ export function TestUi1Component() {
|
||||
<TextEdit
|
||||
ref={textEditRef}
|
||||
name="TextEdit"
|
||||
text=""
|
||||
text={text}
|
||||
custom_minimum_size={new Vector2(200, 35)}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user