GUI: Editting Value in a textbox

1 vue (au cours des 30 derniers jours)
Nour Mawla
Nour Mawla le 17 Mai 2015
Commenté : Walter Roberson le 17 Mai 2015
Good afternoon
Please I need your advice: how do I overwrite text in a textbox without deleting the old data...
i.e is the textbox already contains the letter "a" and I need to add the letter "b" , the first letter won't be deleted....but instead the textbox would contain "ab"
the textbox won't reset unless I manually cleared it...
please help

Réponses (1)

Geoff Hayes
Geoff Hayes le 17 Mai 2015
Nour - you could get the value from the edit text control, then append or concatenate the second character to it, and set the edit text control with the new string. For example,
% get the current string from the edit control
str = char(get(handles.edit1,'String'));
% update the string with the letter 'b'
str = [str 'b'];
% set the text control with the new string
set(handles.edit1,'String',str);
The above assumes that you are using GUIDE to create your GUI and that the edit text control is named (tagged) as edit1.
  1 commentaire
Walter Roberson
Walter Roberson le 17 Mai 2015
Note that at least with the original Handle Graphics:
If you try to use a uicontrol KeyPressFcn callback to get access to what the user is typing as they type it, that the String property of the uicontrol will not be updated until the control is activated by pressing Enter.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by