When using a InputBox
I can add a default value for the text field. Like this:
inputbox('value Enter', 'enter a value', 'default value');
Unfortunately, the cancel button can not be used properly. When cancel is pressed, the inputbox
gives the default value. Which is not ideal.
There also exists a 'inputquery' dialog, which has a functioning dialog, but no options for a default value.
inputquery('Title', 'enter a value', variabile1);
This pretty much leaves the only option of designing a new form to use as a dialog, but that is also not ideal.
Is there a dialog which has a functioning cancel button and a option for default values?
CodePudding user response:
In fact, the InputQuery
function does allow you to set a default value:
var S := 'Sir Anthony Frogkins';
if InputQuery('Frog Simulator', 'Please enter the name of the frog:', S) then
ShowMessageFmt('Frog name: %s', [S]);
In fact, from the documentation of the InputQuery
function:
Value
is the value that appears in the edit box when the dialog box first appears and which returns the value that the user enters.
So you could have realised this even without asking at Stack Overflow! I think this is why every computer programming course in the world1 starts with the same, important lesson: "Always read the documentation of the API you are using."
1 My imaginary dream world.