execute fcn by a change of a Property
Mostra commenti meno recenti
Hey Guys, Imagine I would have 1000 Buttons, which calculate some Data and then put the Solution into a Listbox. Everytime I hit a Button the Listbox is filled. Now I need a Code, that excutes everytime the Listbox gets filled and checks wheter there are Elements twice. I have no idea how to do that: Callbacks are now solution i guess....
Risposta accettata
Più risposte (1)
Adam
il 24 Set 2014
2 voti
Personally I would use a class to represent your data and add a listener to that class, but that would require you to read up about object-oriented programming in Matlab.
Working purely with things attached to the handles structure under a GUI is ok to a certain extent, but when your program starts to get complicated you ideally need some better underlying data structures to manage your data. This also has the advantage of being decoupled from your UI so that you could also run the core of your program from a command-line instruction for example.
Linking your functionality too strongly to the concept of pressing buttons on a UI can make it difficult to extend and use in different settings if the need arises. Programming it based on the actions that are performed (e.g. a function call on a class object to set some data which can in turn notify listeners that a change has been made) gives greater flexibility that you can then attach a lightweight UI to, whether that be buttons or some other methods of triggering the functionality.
provides good documentation on classes and using listeners with them if you wish to go down that route.
Categorie
Scopri di più su App Building in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!