How to add data to an edit field component when a button a pressed in matlab app design

8 ビュー (過去 30 日間)
Ok so, is it possible to add some value to an edit field component when a button is pressed in the MATLAB app? So for example, say you have some buttons 'H', 'E', 'L' and 'O', and an edit text field, when you press a button, the corresponding text is output on the edit field and concatenated to the right of the previous input, so, if you press 'H', 'E', 'L', 'L', 'O' the edit field reads 'Hello'?
I have tried this so far in the callback event as the button in pressed:
set(app.EditField, 'String', [get(app.EditField, 'String'), 'H']);
Likewise for the other buttons, but MATLAB fails to run this line.
Any help would be much appreciated. Thanks so much!

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 3 月 14 日
It is possible, but your code will have to do the concatenation. The default behavior is for the new value to replace the current value.
  3 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 3 月 14 日
編集済み: Cris LaPierre 2021 年 3 月 15 日
Edit fields do not have a string property.
This can be done more succinctly using the functional form rather than set/get.
app.EditField.Value = app.EditField.Value + "H";
By the way, this code goes in the callback for the "H" button, not the editfield.
Tb
Tb 2021 年 3 月 15 日
Yes this has worked thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by