【发布时间】:2016-10-26 12:45:45
【问题描述】:
我在 MATLAB 应用程序中使用 GUI。
我使用uitable 对象。然后我发现有趣的undocumented feature 如何对其数据进行排序、选择整行等等。
我是这样做的:
% create jhandle to my uitable object
juiTable = findjobj(handles.uitable1,'class','UIScrollPane');
jtable = juiTable(1).getComponent(0).getComponent(0);
%... some my action like this:
jtable.setRowSelectionAllowed(true);
%...
%and now lets try use callback for selected cell in uitable:
juiFunHandle = handle(jtable, 'CallbackProperties');
set(juiFunHandle, 'MousePressedCallback', @CellSelectionCallback);
set(juiFunHandle, 'KeyPressedCallback', @CellSelectionCallback);
效果很好。
现在问题:如何将多个参数放入CellSelectionCallback?
我想要这个函数做一些动作(让一些按钮激活等)。
为此,我尝试将 GUI handles 放入其中。但是怎么做呢?
我的CellSelectionCallback 功能:
function CellSelectionCallback(juiTable, varargin)
% get it from the example
row = get(juiTable,'SelectedRow')+1;
fprintf('row #%d selected\n', row);
附:我看到了varargin。那么我可以使用多个参数吗?如何使用我的set 函数??
【问题讨论】:
标签: matlab user-interface matlab-guide function-handle