我用 Matlab 的 AppDesigner 开发了一个 GUI。为了获得鼠标点击,我ButtonDownFcn
为我绘制的图像设置了回调。然后在回调中我阅读了hit.IntersectionPoint
:
ax = app.UIAxes;
ih = imagesc(I, 'Parent', ax);
ih.ButtonDownFcn = {@im_ButtonDownFcn, app};
_
function im_ButtonDownFcn(im, hit, app)
mouse_pos = flip(round(hit.IntersectionPoint(1:2))); %[NaN NaN NaN]
在我的电脑上一切正常,但在同事的电脑上,它返回 NaN。据我们所知,区别在于:
Mine (works) Colleague (NaN)
Win10 MacOS
USB Mouse Laptop Trackpad
有谁知道这些是否可能是IntersectionPoint
返回 NaN 的一个因素?或者有其他可以解决问题的建议?
我在这里读到IntersectionPoint
只有从 2018a 起才可用。我的同事使用的是 2017b,但是当我在我的计算机上测试 2017b 时,IntersectionPoint 仍然有效。