How do I assign a context menu to only the column header row of a uitable?

2 ビュー (過去 30 日間)
Will
Will 2017 年 1 月 12 日
編集済み: Will 2017 年 1 月 17 日
Using MATLAB R2015b... I'm doing something like this:
Table = uitable(...);
TableMenu = uicontextmenu;
MenuItem1 = uimenu(TableMenu,'Label','option 1');
MenuItem2 = uimenu(TableMenu,'Label','option 2');
set(Table,'UIContextMenu',TableMenu)
This results in the context menu appearing whenever there's a right-click anywhere within the table. But I only want it to appear when right clicking on the column header of the table.
I access the column header like so:
jTable = findjobj(Table);
jColHead = get(jTable,'ColumnHeader');
But I don't know how to assign the MATLAB uicontext menu to this or if it's possible ( findjobj(TableMenu) doesn't return anything usable but the AccessibleContext property of jColHead looks promising).
Anyone know of a way to do this?
Alternatively, I would forget assigning the context menu at all and do set(TableMenu,'Visible','on') when right click detected on the column header (I know it's within 25 pixels south of the top of the table) within Table's ButtonDownFcn.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2017 年 1 月 12 日
Will - which version of MATLAB are you using?
Will
Will 2017 年 1 月 13 日
Hi Geoff - I'm using MATLAB R2015b

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by