user-interface - 接受换行符的简单文本输入字段

标签 user-interface wolfram-mathematica

有没有一种简单的方法可以让它发挥作用?

text = "";
DialogInput[{TextCell["Try to type a text with linebreaks :-)"],
  InputField[Dynamic[text], String], 
  Button["Ok", DialogReturn[text]]}]

问题是 InputField 在输入 Return 后终止.我只想要一个简单的文本输入字段。

最佳答案

感谢列昂尼德的提醒。这是代码:

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"]]}]

FrontEndExecute 语句在此版本中稍微简单一些。

顺便说一句,要清除 NotebookEventActions 的默认 Return 键操作,您可以使用 NotebookEventActions->{} .这对于阻止对话框在输入过程中消失很有用。

关于user-interface - 接受换行符的简单文本输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6946475/

相关文章:

Python Tkinter返回csv文件目录

python - 如何根据邻居之间的给定标准将数组拆分为几个较小的数组

fonts - 将 StandardForm I/O 的默认字体从 'New Courier' 更改为 'Consolas' ?

c++ - Qt4 小部件 : implementing a wait function without blocking the widget

ios - 如何制作像 propellerhead 的应用程序 "Figure"这样的自定义 Controller ?

android - 在 flutter 中打开对话框时检测返回按钮按下

wolfram-mathematica - 备份文件在内存中的说明

wolfram-mathematica - 数学 : branch points for real roots of polynomial

wolfram-mathematica - 如何替换 Mathematica 中的隐式子表达式?

c++ - 显示未显示在 qt 中其他类的文本框中