フィルターのクリア

How to use keypress callback and datacursor mode together in app designer?

8 ビュー (過去 30 日間)
Leah Samet
Leah Samet 2020 年 11 月 19 日
回答済み: Christian Mier 2023 年 2 月 7 日
I have a matlab app created using app designer. I want to use datacursormode in order to update the datatips on different plots that I am using, but when I enable datacursor mode my KeyPressFcn callback stops responding. Anyone have this problem and find a solution?
  1 件のコメント
Christian Mier
Christian Mier 2023 年 2 月 6 日
I have the same problem. Did you find any solution?

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

回答 (1 件)

Christian Mier
Christian Mier 2023 年 2 月 7 日
Hello @Leah Samet, I found a solution that it may be helpfull for you or other people. The problem is that once the datacursor mode is enable, the KeyPressFcn is blocked. So, if you want to continue using the KeyPressFcn and at the same time move the data cursor, you can use the following code:
function UIFigure2KeyPress(app, event)
key = event.Key;
app.cursor = datacursormode(app.UIFigure2); %this line can alse be in the startupFcn
if key(1)=='r' %"r" stands for rightarrow
app.cursor.Figure.CurrentObject.Children.DataIndex=app.cursor.Figure.CurrentObject.Children.DataIndex+1;
elseif key(1)=='l' %"l" stands for leftarrow
app.cursor.Figure.CurrentObject.Children.DataIndex=app.cursor.Figure.CurrentObject.Children.DataIndex-1;
end
end

カテゴリ

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

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by