Azzera filtri
Azzera filtri

Change the event of one button as another is pressed in matlab app designer

14 visualizzazioni (ultimi 30 giorni)
So, say you press a button in matlab, can it be used to change the function/event executed by a different button?
function Button1Pushed(app, event)
app.EditField.Value = "Hello"
end
% Button pushed function: InverseButton
function Button2Pushed(app, event)
app.Button1Pushed= "Goodbye" %doesn't work
end
This is what I have done so far.

Risposte (1)

Mohammad Sami
Mohammad Sami il 15 Mar 2021
Instead of using a fixed string value in your function. create a property in your app and use that. you can then modify its value in another function, which will change the behaviour of the other function.
% under properties section
properties (Access = private)
myvalue = "Hello"; % default value.
end
% under functions section
function Button1Pushed(app, event)
app.EditField.Value = app.myvalue;
end
% Button pushed function: InverseButton
function Button2Pushed(app, event)
app.myvalue = "Goodbye" %change the default value
end

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by