Disable middle mouse button interaction with axes

18 Ansichten (letzte 30 Tage)
Jim Hokanson
Jim Hokanson am 10 Dez. 2025
Beantwortet: Aditya am 17 Dez. 2025
Is it possible to disable the middle mouse button interacting with axes?
The two solutions I've seen so far are:
1) disable all mouse interactions
2) override the mouse down function on the axes
I'd like to maintain interactivity and not block the button down function. Is there a more specific approach that can be used?

Antworten (1)

Aditya
Aditya am 17 Dez. 2025
Hi Jim,
There is no built-in MATLAB property or callback to specifically disable only the middle mouse button’s default interaction with axes (like panning/zooming), while leaving all other interactions untouched and without blocking the ButtonDownFcn.A. Custom WindowButtonDownFcn Filtering
This can be a workaround , You can set a WindowButtonDownFcn on the figure, check if the middle button is pressed, and (optionally) interrupt or ignore the event. You cannot truly "block" the built-in pan/zoom/rotate tools from within this callback.
fig = gcf;
fig.WindowButtonDownFcn = @(src,evt) ...
disp(['Button: ', num2str(fig.SelectionType)]);
  • fig.SelectionType will be 'extend' for middle mouse.
  • You could, for example, set the pan tool off if middle is detected.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by