如何在 JMP 應用程式中獲得 TextEditBox 的「取得文字變更」功能?大家好,
我過去在這裡找到了許多有用的解決方案,謝謝您。但現在我有一個問題我還沒有找到解決方案。
我有一個帶有 TextEditBox 和兩個 TextBox 的 JMP 應用程式。文字方塊僅用於結果的可視化。我想觸發一些操作,具體取決於輸入文字期間此 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" )
);
);

在執行第一次提交之前可能會出現一些奇怪的行為(點擊文字編輯框外部或按 Enter 鍵)。
回覆:如何在 JMP 應用程式中為 TextEditBox 取得「取得文字變更」功能?腳本怎麼樣:

每當使用者選擇文字編輯框並完成該操作時,腳本就會被觸發。
腳本似乎稍微「領先」於Text Changed :
當您將 displ_txt() 放在那裡時,一旦使用者完成輸入,它就已經返回新的長度 - 而不是 1 步之後。
回覆:如何在 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 );