Change Dialog values

Hello there o/

I want to change the value in dialog elements on the fly.
For example, there are radiobutton components and I want to change the file extension of the file component when switching them:

:radio{
	id="fontTypeMFK",
	label="Export as:",
	text="Millfork (Text)",
	selected=true,
	onclick=function()
		dlg.data.filename=app.fs.joinPath(app.fs.filePath(lay.sprite.filename), title .. ".mfk")
		dlg:repaint()
	end
}:newrow()
:radio{
	id="fontTypeBIN",
	text="Binary",
	selected=false,
	onclick=function()
		dlg.data.filename=app.fs.joinPath(app.fs.filePath(lay.sprite.filename), title .. ".fnt")
		dlg:repaint()
	end
}
:file {
	id="filename",
	label="File name:",
	save=true,
	focus=false,
	filename=app.fs.joinPath(app.fs.filePath(lay.sprite.filename), title .. ".fnt")
}

When switching radiobuttons no errors occur, but the filename value does not change either?

What am I doing wrong?

Try using Dialog:modify.

local dlg <const> = Dialog()
dlg:file { id = "foo" }
dlg:radio { id = "bar", onclick = function()
    dlg:modify { id = "foo", filename = "baz" }
end
}
dlg:show()
1 Like

OOO! Thank you so much! This really works!

It would be great if the documentation had more examples.