can i call app designer CallBack Functions outside the app ?

37 views (last 30 days)
Ibrahim Essam
Ibrahim Essam on 12 Apr 2017
Commented: Sarah Bell on 22 Apr 2018
i want to know if it is possible to call for example
from an external .m script
so i want to process some data in my matlab script then i call callbacks functions
i tried this
but it gave me error no class or public property called buttonpushedcallback in myapp

Answers (1)

Adam on 12 Apr 2017
Edited: Adam on 12 Apr 2017
Yes, it is possible, but you need to understand the basics of function scope.
would be wrong in all contexts. You either put a. at the front or you pass a in as an argument, you don't do both because they amount to the same thing so you would be passing it in twice, as the first two arguments with this syntax.
You use
a.buttonpushedcallback( )
buttonpushedcallback( a )
if a is an object of a class and buttonpushedcallback is a method of that class. For a method that is not part of the class you just call
buttonpushedcallback( )
If you really want you can have a method that is external to the class that still takes an object of it as first argument:
buttonpushedcallback( a )
but you cannot use the a.buttonpushedcallback syntax here. Quite why you would want to do this I don't know, since if it takes the class object as argument it should be a method of the class in general, but it is possible.
For a callback though you generally need to pass in two arguments representing the source and event data though also for it to be recognised as a valid callback signature.
Sarah Bell
Sarah Bell on 22 Apr 2018
Thank you so much! This just fixed my code, and now I can not only submit it 14+ hours early but I'm probably going to get the best mark I've ever had on any coding based coursework, so thank you again!
While I have you here, my boyfriend is also doing coding coursework and was wondering if you happen to know anything about the Kernighan-Lin (or KL) algorithm in Matlab?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!