textField doesn't update bound property
已回答
I have a form in my plugin with some text fields:
class MyPluginConfigurationForm {
data class Values(
var url: String,
// other vars
)
lateinit var vals: Values
private lateinit var settings: Settings.Data
fun getPanel(): DialogPanel { // is called after createUI()
return panel {
row("Settings") {}
row("Url:") {
textField(prop = vals::url)
}
// other rows with text fields bind to properties
}
}
fun createUI(project: Project) {
settings = Settings.getInstance(project)
vals = Values(
url = settings.url,
// other args
)
}
fun isModified(): Boolean {
return vals.url != settings.url // and comparing other properties
}
fun apply() {
settings.url = vals.url
// other settings update
}
}
So when I update value in the text field (when running IDE with the plugin and opened that form), the property value is not updated - therefore nothing has changed in Settings.Data object.
Is there any obstacles of binging property to text field with textField() DSL function ? Maybe i missed something when created the form and panel?
请先登录再写评论。
Please try using com.intellij.openapi.options.BoundConfigurable. You can also find sample implementations in IJ community sources. Otherwise, please post link to full plugin sources.