Creating a delete button in App Designer

조회 수: 9 (최근 30일)
Leah Griffiths
Leah Griffiths 2019년 4월 17일
답변: Geoff Hayes 2019년 4월 17일
Hello!
I'm relatively new to MATLAB and programming. I'm making a simulation in App Designer to mimic a keypad interface.
I have buttons from 0-9, a clear all button, a delete button an output button that displays the text inputted and takes you to another app window when the output button is pushed.
What should I write in the delete button callback so that when the delete button is pushed it deletes the last character in the output display?
Here is what I have so far...
% Button pushed function: 1Button
function 1ButtonPushed(app,event)
str = strcat(app.OutButton.Text, '1');
app.OutButton.Text = string(str);
end
% Button pushed function: 2Button
function 2ButtonPushed(app, event)
str = strcat(app.OutButton.Text, '2');
app.OutButton.Text = string(str);
end
% Button pushed function: 3Button
function 3ButtonPushed(app, event)
str = strcat(app.OutButton.Text, '3');
app.OutButton.Text = string(str);
end
% And so on for the rest until 0...
% Button pushed function: ClearButton
function ClearButtonPushed(app, event)
app.OutButton.Text = '';
end
% Button pushed function: DelButton
function DelButtonPushed(app, event)
???
end
% Button pushed function: OutButton
function OutButtonPushed(app,event)
app2
closereq;
end

채택된 답변

Geoff Hayes
Geoff Hayes 2019년 4월 17일
Leah - your delete button callback could look something like
function DelButtonPushed(app, event)
app.OutButton.Text = app.OutButton.Text(1:end-1);
end
I'm assuming that app.OutButton.Text is just a string that we can then remove the last character from.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by