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