How to give call back function in app design using MATLAB.

2 views (last 30 days)
I'm creating an app in app design using MATLAB. I want to give call back function for the edit text value in MATLAB. Let me give brief explanation of my work. In the design view, i have editnumeric field named as "Number of Tabs" and enter button. whereas in the editnumeric field if I give numeric value as 3 and clicked on enter button. Then i'm getting 3 tabs. In each tab there is, Number of Boxes : "input box to enter value" ---> "enter button". If i click on "enter button" after giving value in "input box" that describes number of boxes, i should get that many input boxes in that tab and it should be dynamically vary from each tab.[e.g: In tab 1 - Number of Boxes: "3" ---> clicked on enter button---> 3 input boxes should generate]. I want to give call back function to the 'enter buttom' which is in tab section so that i can generate input boxes based on the input value i have given in the number of boxes.

Answers (2)

Voss
Voss on 2 Apr 2024
Edited: Voss on 2 Apr 2024
Since the editfield for number of boxes and the enter button for getting dynamic input boxes are created programmatically, specify their callbacks programmatically.
For instance, if your code that creates an editfield looks like:
new_edit = uieditfield(p,'numeric','Value',0)
then just include a ValueChangedFcn in the arguments:
new_edit = uieditfield(p,'numeric','Value',0,'ValueChangedFcn',@cb_edit)
and define the calback function cb_edit appropriately.
Or, if you are using copyobj to create the new ui components, you can specify their callbacks after they are created, e.g.:
new_edit = copyobj(old_edit,p); % create the thing
new_edit.ValueChangedFcn = @cb_edit; % then set its callback
  3 Comments
Voss
Voss on 3 Apr 2024
You're welcome! If you have any other questions, please let me know.
Vaibhavi Pallavaneni
Vaibhavi Pallavaneni on 3 Apr 2024
I'm unable to write the code to read the value of edit text in the tab for generating dynamic input boxes.

Sign in to comment.


Taylor
Taylor on 2 Apr 2024
To add a callback to a component, open the app in design view. Right-click the component you want to add a callback for and select the appropriate option from the menu. It sounds like you will want a ValueChangedCallback. Once you select the type of callback from the menu, you will automatically be brought to the location of the callback in code view.
  1 Comment
Vaibhavi Pallavaneni
Vaibhavi Pallavaneni on 2 Apr 2024
Edited: Vaibhavi Pallavaneni on 2 Apr 2024
Thanks for your response. Editfield for number of boxes and the enter button for getting dynamic input boxes won't be in the design view. Those are the responses after the code runs. Only Number of tabs and enter button is available in design view.I think I'm clear about my question.

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!