无法从字段中的文本区域获取输入字符串

Cannot get input string from textarea in field

尝试在用户单击提交按钮时从文本字段中获取用户的输入,但我无法在文本字段函数中设置变量(它被设置为空白,因为没有更新),并且无法访问文本区域来自场外节点

form {
    //other code
    var textField = field("Short description of action") {
        var textArea = textarea {
            prefRowCount = 1
            maxWidth = 400.0
            hgrow = Priority.ALWAYS
            //actionDescription = this.text //does not update value
        }
    }
    buttonbar {
        var statusText = field("Save status will appear here")
        button("Save baby action") {
        actionDescription = (textField.children[1] as TextArea).text
        //actionDescription = textField.textArea //does not recognize
        //actionDescription = textField.text //wrong, "Short description of..."
        action {
            if (actionDescription.isEmpty()) {
                statusText.text = ("Must enter short description")
            } else {
                 //do some work with inputText
            }
        }
   ...

编译器知道转换永远不会工作,但使用调试器似乎文本区域是文本字段的子 #2 或 [1],但我无法在此或任何 children.Please 让我知道为什么这个简单的访问给我带来麻烦——谢谢!

通过将 textArea 的 textProperty 绑定到整个视图或表单范围内的字符串 属性 获得它,然后检查该值是否为空!