code for a delete button in matlab gui

hello :) im doing a scientificcalculator GUI in Matlab, how can I code for a delete button for my calculator? its like deleting(just like backspace) characters from a static text box?

 Respuesta aceptada

jaybee
jaybee el 30 de Sept. de 2012
Editada: jaybee el 30 de Sept. de 2012

0 votos

could you make it simplier? im a starter in gui making.

4 comentarios

Matt J
Matt J el 30 de Sept. de 2012
Simpler in what way? Which of the 3 steps I outlined don't you know how to do? Hopefully, step 2 was straightforward enough. I gave you a direct example.
jaybee
jaybee el 30 de Sept. de 2012
function pushbutton20_Callback(hObject, eventdata, handles)
screen = get(handles.text1, 'String');
screen = strcat( screen );
set( handles.text1, 'String', fprintf('%f\b\n', screen))
itried this but it failed, what should i edit here?
Matt J
Matt J el 30 de Sept. de 2012
screen = get(handles.text1, 'String');
screen(end)='';
set( handles.text1, 'String', screen)
jaybee
jaybee el 30 de Sept. de 2012
thankyou so much matt j :)

Iniciar sesión para comentar.

Más respuestas (2)

Jan
Jan el 30 de Sept. de 2012
Care for the empty input also:
screen = get(handles.text1, 'String');
if ~isempty(screen)
screen(end)='';
set(handles.text1, 'String', screen);
end
Matt J
Matt J el 30 de Sept. de 2012

0 votos

In the callback for the delete button you would
(1) Read the string from the text box.
(2) Truncate the string like in the example below
(3) Write the truncated string back into the text box
>> str='myString'
str =
myString
>> str(end)='' %truncate
str =
myStrin

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Sept. de 2012

Editada:

el 2 de Dic. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by