Duplicated elements in a GUI
1 次查看(过去 30 天)
显示 更早的评论
Dear all, I have a gui with 20 different tables. They all perform the same calculation with the data entered in each one of them by the user.
At the moment I have this in my function:
function uitable1_CellEditCallback(hObject, ~, handles)
calculation
function uitable2_CellEditCallback(hObject, ~, handles)
calculation
function uitable3_CellEditCallback(hObject, ~, handles)
calculation
Any chance to do that in a cleaner way without having to repeat the same block of code over and over?
Thanks!
0 个评论
回答(4 个)
Sean de Wolski
2013-11-8
Absolutely.
You can go into GUIDE and use the property inspector to change the callback manually. Copy the callback from the first UITABLE's GUIDE Inspector window and paste it into the others. Now you'll have one callback for all of them and have them all point at it.
Inside of the Callback, the first input hObject is the handle to the specific uitable that is calling the callback. Thus if you need some logic based on the calling uitable, you have it there.
0 个评论
Shaun VanWeelden
2013-11-8
Have them all point to the same callback and use the hObject variable to differentiate them. hObject is the current object being used and you can do your get/set stuff based on the hObject
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!