¿Cómo obtener una funcionalidad "Obtener texto modificado" para un TextEditBox en una aplicación JMP?Hola a todos,
He encontrado muchas soluciones útiles aquí en el pasado, gracias por eso. Pero ahora tengo una duda a la que aún no he encontrado solución.
Tengo una aplicación JMP con TextEditBox y dos TextBoxes. Los TextBoxes son sólo para la visualización del resultado. Quiero activar alguna acción, dependiendo de la longitud actual del texto en este TextEditBox durante la introducción del texto. Para el script JSL, hay una función en el índice de script (GetTextChanged), pero ¿cómo puedo obtener esta funcionalidad en la aplicación JMP?
Llamo a la función "displ_txt()" con el script "TextChanged" en la sección de objetos de TextEditBox e intenté lo siguiente en la pestaña Scripts, pero no funciona.
Yo uso 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" )
);
);
Gracias de antemano,
Mate
Automatización y secuencias de comandosventanasRe: ¿Cómo obtener la funcionalidad "Obtener texto modificado" para un TextEditBox en una aplicación JMP?¿Qué intentas hacer con Cambiar texto? Obtener texto cambiado le devuelve la función vinculada a Establecer texto cambiado del cuadro de edición de texto.
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" )
);
);

Puede haber algún comportamiento extraño hasta que realice la primera confirmación (haga clic fuera del cuadro de edición de texto o presione Intro).
Re: ¿Cómo obtener la funcionalidad "Obtener texto modificado" para un TextEditBox en una aplicación JMP?¿Qué tal el guión?

Cada vez que los usuarios seleccionan el cuadro de edición de texto y terminan allí, se activará el script .
El script parece estar ligeramente "por delante" del Texto cambiado :
Cuando coloca displ_txt() allí, ya devuelve la nueva longitud una vez que el usuario termina la entrada, no 1 paso después.
Re: ¿Cómo obtener la funcionalidad "Obtener texto modificado" para un TextEditBox en una aplicación JMP?Este código debería darle algunas 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: ¿Cómo obtener la funcionalidad "Obtener texto modificado" para un TextEditBox en una aplicación JMP?Gracias por su respuesta. Desafortunadamente, mi objetivo era obtener el texto sin compromiso. Por tanto, Script no hará exactamente lo que quiero.
Re: ¿Cómo obtener la funcionalidad "Obtener texto modificado" para un TextEditBox en una aplicación JMP?Gracias, pmroz. Su solución me llevó al siguiente código, que funciona según lo previsto.
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 );