フィルターのクリア

AppDesigner UIFigure WindowScrollWheelFcn disables datatips

3 ビュー (過去 30 日間)
Drew
Drew 2024 年 5 月 21 日
コメント済み: Adam Danz 2024 年 5 月 22 日
I am building an app in AppDesigner r2021a. I have several plots with custom datatips on different tabs. Everything works great.
However, when I add a WindowScrollWheelFcn callback to the parent uifigure, I am no longer able to see datatips when hovering over points.
Is there anyway around this?

採用された回答

Adam Danz
Adam Danz 2024 年 5 月 22 日
> when I add a WindowScrollWheelFcn callback to the parent uifigure, I am no longer able to see datatips when hovering over points.
I can recreate this problem using the follow reduced reproduction steps.
app.UIFigure = uifigure();
app.UIAxes = uiaxes(app.UIFigure);
app.Lines = plot(app.UIAxes, rand(5),'x','LineWidth',3);
% Without this section below, datatip interactions work as expected
app.UIFigure.WindowScrollWheelFcn = @windowScrollFcn;
function windowScrollFcn(obj, event)
% Scroll wheel controls figure size - for testing purposes
obj.Position(3:4) = obj.Position(3:4)+10*event.VerticalScrollCount;
end
There is a workaround available starting in MATLAB R2023a where the datatip button in the axes toolbar can toggle on interactive datatips. When the Data Tips button in the axes toolbar is enabled, the WindowScrollWheelFcn is temporarily disabled. It is enabled again after de-selecting the Data Tips button in the axes toolbar and existing datatips are preserved.
I am not aware of a workaround prior to R2023a.
  2 件のコメント
Drew
Drew 2024 年 5 月 22 日
Thank you for your answer - this pointed me in the right direction.
I was able to code a workaround in r2021a based on your description of the behavior in r2023a since the axes where I want datatips and the UI component where I want a scroll callback live on different tabs.
I set a callback for TabChangedFcn to set app.UIFigure.WindowScrollWheelFcn = @windowScrollFcn if I am on the tab where I want that behavior and app.UIFigure.WindowScrollWheelFcn = '' if I want datatips.
A similar workaround should be possible based on mouse position or really anything else, it doesn't have to be selected tab, I don't think, but this let me have datatips and a scroll wheel callback under the same parent UIFigure.
Adam Danz
Adam Danz 2024 年 5 月 22 日
Good idea!
That reminds me of an old answer of mine that might come in handy.
You can use a pointer manager to do something when the pointer enters, traverses, or leaves an object. For example, when it enters axes, it can turn off the WindowScrollWheelFcn and when it exits, it can turn it back on.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by