Correct way to fetch data from a GUI with nested menus.
Show older comments
Goodmorning everyone.
I'm developing a GUI for a program that simulates the interactions between different components. Since every component has a long list of fields, the gui is structured as a main menu with pop up buttons that open different sub menus, one for each component (example: push button A opens a menu for Component A, push button B opens a menu for Component B). To create the menus I'm using GUIDE.
What I want to do is to have a separate struct for every component into the main gui, so I can better manage all the functions with push buttons from the main menu, and fetch data from the sub-menus into these structs.
Problem is that I'm having a really hard time understanding how to pass and save data from the sub-menus to the main menu.
For example, the initialization of values goes as follows:
% --- code that generates main gui before this line --- %
global ComponentA;
global ComponentB;
% struct initialization
initializeGUI(ComponentA, ComponentB);
%initializeGUI does a bunch of: ComponentA.value = 1;
% debug
disp(ComponentA);
% --- code that generates all the callback functions for the gui buttons below this line --%
The disp(ComponentA) returns an empty struct, while if I do the same thing inside initializeGUI.m it returns all the data correctly.
So, what is the correct way to pass structs to and fetch data from the sub menu?
Accepted Answer
More Answers (0)
Categories
Find more on App Building 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!