Need a row-specifi or cell-specific context menu for uitable

4 次查看(过去 30 天)
I need to assign a row-specific or a column specific context menu for a uitable (within uifigure).
I know how to create a global context menu, but I need it to be different for every row (or cell) of the table.
Tricks with learning cursor position won't work, as the table is larger, than it is shown on the screen and I use sliders to navigate through it.
The Matlab version is 2020a.

回答(1 个)

Divyanshu
Divyanshu 2024-9-24
编辑:Divyanshu 2024-9-24
A possible way to achieve location specific context-menu opening through App designer is adding the following piece of code inside the callback function defined for 'ContextMenuOpeningFcn' property of 'uicontextmenu()':
row = event.InteractionInformation.Row;
col = event.InteractionInformation.Column;
app.currentRow = row;
app.currentColumn = col;
% The above piece of code enables you to track the row and column of a UITable which user
% has clicked or from which the context-menu is triggered.
I have used this code for version R2023b, there it works well but not sure if it will work for earlier versions of MATLAB.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by