Hi, all. I created a custom dialog named "dialog1", and I put an edit box named "edit1" control in it.
I intention is to put some preset text in edit1 control. but the red box line gives error.
How to fix?
Thanks.
Hi, all. I created a custom dialog named "dialog1", and I put an edit box named "edit1" control in it.
You need to call Dlg.Create before setting the value. I think that is all that’s needed.
Might need dlg.detach = true;
before the dlg.Create();
.
If that still doesn't work, please paste the code as text so we can try it.
For a "real" dialog, you probably need to call
dlg.GetMsg();
and check
dlg.result
Not working.
function OnClick(clickData)
{
// Create a new Dlg object
var dlg = DOpus.Dlg;
dlg.template = "dialog1";
dlg.detach = true;
dlg.Create();
dlg.Control("edit1").Value = "preset text";
// Show the dialog
var ret = dlg.Show();
// Check if OK was pressed and retrieve the text
if (ret == 1) // 1 is typically the return value for 'OK'
{
// Change 'myInputBox' to the actual name of your input box control
var userInput = dlg.Control("edit1").value;
// Now userInput variable contains the text from the input box
DOpus.Output("User entered: " + userInput);
// You can now use userInput variable as needed
}
}
We need the Resources tab's text as well. (Or copy & paste the whole button, from the toolbar.)
Thanks, but I have no clue how to integrate your code with mine. I simply put it somewhere I see fit, it just gives error.
Maybe we have located the origin of the error. I don't use button or resource tab. I simply created one marked with red box.
I pondered a while and I think maybe you are talking about this:
new custom dialog.dcf (2.7 KB)
function OnClick(clickData)
{
// Create a new Dlg object
var dlg = DOpus.Dlg;
dlg.template = "dialog1";
dlg.Create();
dlg.Control("edit1").Value = "preset text";
// Show the dialog
var ret = dlg.RunDlg();
// Check if OK was pressed and retrieve the text
if (ret == 1) // 1 is typically the return value for 'OK'
{
// Change 'myInputBox' to the actual name of your input box control
var userInput = dlg.Control("edit1").value;
// Now userInput variable contains the text from the input box
DOpus.Output("User entered: " + userInput);
// You can now use userInput variable as needed
}
}
It works fine. Thanks very much.