How to get a "Get Text Changed" functionality for a TextEditBox in a JMP Application?Hi all,
I have found many helpful solutions here in the past, thank you for that. But now I have a question to which I have not yet found a solution.
I have a JMP Application with a TextEditBox and two TextBoxes. The TextBoxes are only for the visualisation of result. I want to trigger some action, depending on the current length of the text in this TextEditBox during the entering of the text. For JSL script, there is a function in the scripting index (GetTextChanged), but how could I get this functionality in the JMP Application?
I call the function "displ_txt()" with the "TextChanged" script in the object section of the TextEditBox and tried the following in the Scripts Tab, but it does not work.
I use 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" )
);
);
Thank you in advance,
Matt
Automation and ScriptingWindowsRe: How to get a "Get Text Changed" functionality for a TextEditBox in a JMP Application?What are you trying to do with Get Text Changed? Get Text Changed returns you the function tied to the Text Edit Box's Set Text Changed.
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" )
);
);

There might be some weird behavior until you perform first commit (click outside text edit box or press enter).
Re: How to get a "Get Text Changed" functionality for a TextEditBox in a JMP Application?how about script:

whenever the users selects the text edit box and finishes there, script will be triggered.
Script seems to be slightly "ahead" of Text Changed:
When you place displ_txt() there, it already returns the new length once the user finishes the entry - not 1 step later.
Re: How to get a "Get Text Changed" functionality for a TextEditBox in a JMP Application?This code should give you some ideas:
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("")
);Re: How to get a "Get Text Changed" functionality for a TextEditBox in a JMP Application?Thank you for your answer. Unfortunately, my focus was to get the text without a commit. Thus, Script will not do exactly what I want.
Re: How to get a "Get Text Changed" functionality for a TextEditBox in a JMP Application?Thank you, pmroz. Your solution led me to the following code, which works as intended.
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 );