如何在 JMP 应用程序中获取 TextEditBox 的“获取文本更改”功能?大家好,
过去我在这里找到了很多有用的解决方案,非常感谢。但现在我有一个问题,我还没有找到解决方案。
我有一个 JMP 应用程序,其中包含一个 TextEditBox 和两个 TextBox。TextBox 仅用于结果可视化。我想在输入文本时根据此 TextEditBox 中文本的当前长度触发一些操作。对于 JSL 脚本,脚本索引中有一个函数 (GetTextChanged),但我如何在 JMP 应用程序中获得此功能?
我使用 TextEditBox 的对象部分中的“TextChanged”脚本调用函数“displ_txt()”,并在脚本选项卡中尝试执行以下操作,但它不起作用。
我使用 JMP 18.0.0。
OnModuleLoad( {}, );
thisModuleInstance << Create Objects;
displ_txt = Function( {},
teb_txt = TextEdit1 << GetText;
Try( Text2 << SetText( teb_txt ),"Error" );
If( Length( teb_txt ) > 0,
Show( Length( teb_txt ) ) //Here should be the current length after each change
);
//...what I want to do further is like
If( Length( GetTextChanged( teb_txt ) ) <= 3,
Text1 << SetText( "Len below limit" ),
Text1 << SetText( "Len above limit" )
);
);
先感谢您,
马特
自动化和脚本视窗回复:如何在 JMP 应用程序中获取 TextEditBox 的“获取文本更改”功能?您想用“获取文本更改”做什么?“获取文本更改”将返回与“文本编辑框的设置文本更改”相关的函数。
displ_txt = Function( {},
teb_txt = TextEdit1 << GetText;
Try( Text2 << SetText( teb_txt ),"Not OK" );
If( Length( teb_txt ) > 0,
Show( Length( teb_txt ) ) //Here should be the current length after each change
);
//...what I want to do further is like
If( Length(teb_txt) <= 3,
Text1 << SetText( "Len below limit" ),
Text1 << SetText( "Len above limit" )
);
);

在您执行第一次提交(单击文本编辑框外部或按回车键)之前,可能会出现一些奇怪的行为。
回复:如何在 JMP 应用程序中获取 TextEditBox 的“获取文本更改”功能?脚本怎么样:

每当用户选择文本编辑框并完成时,脚本就会被触发。
脚本似乎略微“领先”于文本更改:
当您将 displ_txt() 放在那里时,一旦用户完成输入,它就会返回新的长度 - 而不是晚一步。
回复:如何在 JMP 应用程序中获取 TextEditBox 的“获取文本更改”功能?这段代码应该能给你一些想法:
filter_text = Function( {this, entered_txt},
{msg},
// only attempt to filter if there is any text
If( entered_txt != "",
if (length(entered_txt) <= 3,
msg = "Len below limit",
msg = "Len above limit"
);
message_tb << set text(msg);
);
); // end filter_text function
nw = new window("Test String Length",
user_tb = textedit box("",
<< set text changed(filter_text)),
message_tb = text box("")
);回复:如何在 JMP 应用程序中获取 TextEditBox 的“获取文本更改”功能?谢谢你的回答。不幸的是,我的重点是获取没有提交的文本。因此,脚本不会完全按照我的要求执行。
回复:如何在 JMP 应用程序中获取 TextEditBox 的“获取文本更改”功能?谢谢 pmroz。您的解决方案让我找到了以下代码,它按预期运行。
filter_text = Function( {this, entered_txt},
{msg},
// only attempt to filter if there is any text
If( entered_txt != "",
If( Length( entered_txt ) <= 3,
msg = Char( entered_txt ) || " is below length limit",
msg = Char( entered_txt ) || " is above length limit"
);
Text2 << set text( msg );
)
); // end filter_text function
TextEdit1 << set text changed( filter_text );