How can I use the ButtonDownFcn of Uitable

12 ビュー (過去 30 日間)
Staffan
Staffan 2011 年 5 月 24 日
回答済み: Clemens Nyffeler 2015 年 1 月 30 日
Hello,
when i click on a uitable (which is enabled), the cellSelectionCallback is executed. - how can I get Matlab to execute the buttonDownFcn? - right click executes buttonDown, but eventdata.Indices are not defined in R2009b, are they in other releases? - CellSelectionCallback sometimes executes several times with different indices, any idea why?
I just want to click somwhere in the uitable and then do something depending on the indices... Would appreciate any help!
Staffan

回答 (1 件)

Clemens  Nyffeler
Clemens Nyffeler 2015 年 1 月 30 日
I had the same problem and found the answer here (For some reason the ButtonDownFcn just doesn't work and is simply useless for the uitable):
You need to use Yair Altman's FindJObj()
And then you can register additional callbacks using the underlying Java object.
jscrollpane = findjobj(htable);
jviewport = jscrollpane.getViewport;
jtable = jviewport.getView;
set(jtable, 'MouseClickedCallback', @onClick);
Where onClick() is a regular matlab function that takes two arguments (handle and eventdata). There are other callbacks you can register as well, like
MouseWheelMovedCallback
MouseClickedCallback
MouseEnteredCallback
MouseExitedCallback
MousePressedCallback
MouseReleasedCallback
... and those are just the ones related to mouse events. Use get(jtable) to find out what else is available.
This works for me in version R2013a.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by