how get the real pos

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 comentarios

dpb
dpb el 12 de En. de 2026
"...but in 2024b it fail[s]"
For what definition of failure? Does it return an error, wrong values, something else...???
ads
ads el 13 de En. de 2026
Sorry, I didn't describe it clearly., i use this script to get the mouse pos in simlink ,it did work in 2022b can return the correct pos, ,but i it return wrong pos in 2024b like this picture you can see the gain is not create in mouse pos ,thanks again.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

ads
el 12 de En. de 2026

Comentada:

ads
el 13 de En. de 2026

Community Treasure Hunt

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

Start Hunting!

Translated by