App Designer how to set value for edit field (numeric)

155 visualizaciones (últimos 30 días)
Egor Liokumovitch
Egor Liokumovitch el 17 de Oct. de 2022
Comentada: Kevin Holly el 17 de Oct. de 2022
Hello,
I'm having issues with the simplest of things. I have an app that opens a "Parameters" window. In this window I should be able to set system parameters, such as:
Carrier Frequency, Carrier Power etc.
I'm trying to edit the initial value from 0, to some default value defined in my main app. I'm not even at a stage of changing this value, just trying to grab the default instead of 0.
From the code view in the app in the "create components function", if I set an initial value manually it adds a line of app.CarrierPowerEditField.Value = 15;
I try to add this line manually at the startup function, but this affects exactly nothing for the actuall app. I still get an edit box with "0".
Only if I add a "set" button, upon press of which it will set app.CarrierPowerEditField.Value = 15 will the value change.
I can add a button for grabbing the default values, but I run into a different issue:
In the main app I create a variable as public property
DefCarPower = 15;
But if I write
app.CarrierPowerEditField.Value = app.DefCarPower;
it says "Unrecognized method, property, or field 'DefCarPower' for class 'SecondWindow'."
What am I doing wrong?
  1 comentario
Kevin Holly
Kevin Holly el 17 de Oct. de 2022
Is this "Parameters" window a dialog box created with inputdlg?
Is the "Parameters" window an app? If so, which startup function are you editing, this app or the main app?
Do you have code that you can share?

Iniciar sesión para comentar.

Respuesta aceptada

Kevin Holly
Kevin Holly el 17 de Oct. de 2022
If the SecondWindow is an app that was called from the mainapp. You will need to call the property value from the mainapp. The current command calls from the SecondWindow app and it does not find it.
It should be something like this:
app.CarrierPowerEditField.Value = app.Callingapp.DefCarPower;
  7 comentarios
Kevin Holly
Kevin Holly el 17 de Oct. de 2022
Note, one says CarrierPowerEditFieldLabel and the other CarrierPowerEditField
Kevin Holly
Kevin Holly el 17 de Oct. de 2022
Please see the two apps attached.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by