Archive 17/01/2023.

SetEchoCharacter() + SetText() = Series Wrong Series of Characters

nickwebha

If both SetEchoCharacter() and SetText() are set and you try to use GetChildStaticCast() you just get a bunch of whatever SetEchoCharacter() was set to.

auto* lineEditPassword = new Urho3D::LineEdit( context_ );
lineEditPassword->SetName( "LineEditPassword" );
lineEditPassword->SetMinHeight( 24 );
lineEditPassword->SetEchoCharacter( '*' );
lineEditPassword->SetText( "password here" );

Urho3D::LineEdit* passwordLineEdit = window_->GetChildStaticCast< Urho3D::LineEdit >( "LineEditPassword", false );

passwordLineEdit does not equal “password here” but instead equals “*************”.

This seems like a bug to me.

JSandusky

Looks correct to me. Which function are you calling that’s returning the echo’d version? If it’s just that you’re seeing the echo’d version in UI then it’s correct.

Are you expecting to be able to static-cast away the properties of a class instance?

nickwebha

Sorry, I should have made this comparison before: I am expecting it to act like the HTMLs <input type="password" />. Visually it is all *'s but when you retrieve the value it is was what was actually typed.

Right now, if I pre-set the text with SetText() (see example above) only *'s come out when retrieving the value.

Edit
Consider the password “password”. In the above example, if I get the value of the LineEdit, all *'s come out instead of “password” (looks like “********”). If I type one character (say “A”) in the middle of it I get “*****A***”.

Is SetEchoCharacter() only supposed to be a visual thing (like HTMLs <input type="password" />, or actually whatever you type into SetEchoCharacter()?

Eugene

Do you mean that if you call “GetText” you get hidden text?
My best bet would be this line:

nickwebha

Correct.

If I do not do SetText() and still use SetEchoCharacter() it works as expected (shows a bunch of *'s but outputs the “real” text). This is in addition to what I mentioned before about typing in the middle of the *'s.

Still feel this is a bug.