Error when calling a PushButton programetically in Appdesigner

1 view (last 30 days)
Amr Elkhrachy
Amr Elkhrachy on 8 Nov 2021
Commented: Amr Elkhrachy on 16 Nov 2021
I am trying to design a Pushbutton in Appdesigner, which when pushed it programetically pushes other buttons, which are present in the same gui. I have tried the following code:
% Button pushed function: SetZeroALLButton
function SetZeroALLButtonPushed(app, event)
ButtonPushed(app, matlab.ui.eventdata.SetZeroButton_5Data)
end
to push this button:
% Button pushed function: SetZeroButton_5
function SetZeroButton_5Pushed(app, event)
app.zero_weg_R = app.FederwegEditField_2.Value;
end
But it doesn't work. Any ideas why it is not working?

Answers (1)

Cris LaPierre
Cris LaPierre on 10 Nov 2021
Pushing a button just triggers the execution of a specific callback function. However, you can also call callback functions manually inside another callback function. Based on what you have shared, my callback function for the first pushbutton might look like this.
% Button pushed function: SetZeroALLButton
function SetZeroALLButtonPushed(app, event)
% run callback for SetZeroButton_5 button
app.SetZeroButton_5Pushed(event)
end
See this answer for another example.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by