how get the real pos
73 views (last 30 days)
Show older comments
i use the script to get mouse pos in simlink window but in 2024b it fail ,i want to know how to fix it,thanks
function pos = saGetMousePosition
mousePosition = get(0,'PointerLocation');
locationBase = get_param(gcs,'Location'); % Screen Left-Top [0 0], and always gets valid value on different screens
scrollOffset = get_param(gcs,'ScrollbarOffset');
screenSize = get(0,'ScreenSize');
zoomFactor = str2double(get_param(gcs, 'ZoomFactor'))/100;
% Calculate new position
p_X = ceil((mousePosition(1) - locationBase(1) + scrollOffset(1))/zoomFactor);
p_Y = ceil((screenSize(4) - mousePosition(2) - locationBase(2) + scrollOffset(2))/zoomFactor);
pos = [p_X, p_Y];
end
2 Comments
dpb
on 12 Jan 2026 at 14:41
"...but in 2024b it fail[s]"
For what definition of failure? Does it return an error, wrong values, something else...???
Answers (0)
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!