Is there a simple way to get this to work?
text = "";
DialogInput[{TextCell["Try to type a text with linebreaks :-)"],
InputField[Dynamic[text], String],
Button["Ok", DialogReturn[text]]}]
The problem is that InputField terminates after typing Return
. I just want a simple text input field.
Thanks for the heads-up Leonid. Here is the code:
text = "";
DialogInput[{TextCell["Try to type a text with linebreaks :-)"],
InputField[Dynamic[text], String, FieldSize -> {30, 6}],
DefaultButton[DialogReturn[text]]},
NotebookEventActions -> {"ReturnKeyDown" :>
FrontEndExecute[NotebookWrite[InputNotebook[], "\n"]]}]
The FrontEndExecute statement is a little simpler in this version.
Incidentally, to clear the default Return key action of NotebookEventActions you can use NotebookEventActions->{}
. This can be useful to stop dialogs disappearing during input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With