Is possible to call a callback each time you change a property (in mytarget.tlc)?
2 次查看(过去 30 天)
显示 更早的评论
Hi, I'm customizing one mytarget.tlc to add new options to my target. I need to put a checkbox so that when the 'on' do one thing and when 'off' do something else. But with the call: rtwoptions(5).Callback = MyCallback (hDlg, HSRC) '; This callback is only called when the property is changed the first time.
0 个评论
采纳的回答
Kaustubha Govind
2012-2-23
What you are doing sounds correct and should work every time the property is changed - maybe there is some small error in implementation? I would recommend looking at an example that is shipped with the product. Look at the files usertarget.tlc and usertargetcallback.m in $matlabroot/toolbox/rtw/rtwdemos/rtwoptions_demo
This is what is used:
rtwoptions(4).prompt = 'Real-Time Interrupt Source';
rtwoptions(4).type = 'Popup';
rtwoptions(4).default = 'Timer';
rtwoptions(4).popupstrings = 'Timer|5|6|7|8|9|10|11|12|13|14|15';
rtwoptions(4).tlcvariable = 'tlcvariable3';
rtwoptions(4).callback = 'usertargetcallback(hDlg, hSrc, ''tlcvariable3'')';
I also tried adding this TLC file to the MATLAB path, and then used this as the System Target File in a test model. I could see the callback being executed every time the parameter was changed.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!