Add properties to edit field in app designer

32 ビュー (過去 30 日間)
Adrián Lascurain
Adrián Lascurain 2023 年 6 月 3 日
コメント済み: Adrián Lascurain 2023 年 6 月 6 日
Hi , I would like to know if is there somehow to add a new property for an edit field object in appdesigner, For instance I'm trying to make a Password field, and I need another property that shows the obfuscated password with '*' but not changing the Value of the edit field (the current password).
I've seen that placeholder property can help you but it only works when edit field is empty. So I would like to know if:
  • A new property can be created (on a existing edit field component) to store the obfuscated password but mantaining the password value?

採用された回答

Matt J
Matt J 2023 年 6 月 4 日
It might be better to use a 3rd party tool like,
to implement a password field.
  1 件のコメント
Adrián Lascurain
Adrián Lascurain 2023 年 6 月 6 日
Yeah I think this would be the best solution thanks a lot

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2023 年 6 月 3 日
編集済み: Matt J 2023 年 6 月 3 日
You can always use the EditField's UserData property to hold extra stuff. However, there's no reason the true password needs to be held within the edit field, as far as I can see. Just create a Hidden app property to hold the true password and make the obfuscated password the traditional value property of the Edit Field.
  4 件のコメント
Diwakar Diwakar
Diwakar Diwakar 2023 年 6 月 4 日
Hi,
PasswordEditValueChanged is the callback function that gets triggered whenever the value of the edit field changes. It retrieves the value using app.PasswordEditField.Value, obfuscates the password by creating a string of asterisks, and then updates the ObfuscatedPasswordLabel component to display the obfuscated password.
Remember to update the names of the edit field (PasswordEditField) and label (ObfuscatedPasswordLabel) components in the code according to the names you've assigned in your app.
% --- Callback function for the edit field ---
function PasswordEditValueChanged(app, event)
password = app.PasswordEditField.Value;
obfuscatedPassword = repmat('*', 1, numel(password));
app.ObfuscatedPasswordLabel.Text = obfuscatedPassword;
end
Adrián Lascurain
Adrián Lascurain 2023 年 6 月 6 日
Thanks a lot diwakar , I'll keep it in mind

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by