Code covered by the BSD License  

Highlights from
Mouse scroll wheel navigation

4.75

4.8 | 4 ratings Rate this file 19 Downloads (last 30 days) File Size: 1.9 KB File ID: #18282
image thumbnail

Mouse scroll wheel navigation

by Gus Brown

 

10 Jan 2008 (Updated 03 Mar 2008)

Navigate figures with the mouse scroll wheel.

| Watch this File

File Information
Description

Tired of clicking the task bar to find the figure window that you want? So was I, so I decided to use the mouse scroll wheel as a way to change the current figure.

This function will update the figure WindowScrollWheelFcn so that the mouse scroll wheel can be used to cycle through figures.

It can also set the default figure create function to automatically activate this function when a new figure is created.

Acknowledgements
This submission has inspired the following:
DOCK and UNDOCK figures into groups
MATLAB release MATLAB 7.4 (R2007a)
Other requirements Mouse with scroll wheel.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
10 Jan 2008 Jiro Doke

Very nice idea.

One comment. You have it so that you can specify the figure handles to apply this functionality (it wasn't clear in the help that you can supply multiple figure handles). But when scrolling, it always scrolls to the next (or previous) figure of all the figures, not just the ones specified. This causes the scroll to halt when it lands on a figure that I didn't specify. For example:

for id = 1:10;
 figure;plot(rand(10,id));
end
GTscroll([1 4 6 8 10])

Scrolling down from 10 takes me to figure 9, and then I can't scroll up or down from there because I didn't specify that figure.

10 Jan 2008 Gus Brown

Good point. I guess I never intended for one to scroll through a limited set of figures, rather all figures. As such when one uses the mouse scroll wheel, the function fetches all the current figures and then chooses the next one.
The option to apply the scroll function to only one figure is there so that the function can be run on new figures.

05 Feb 2008 Riccardo Meldolesi

I must confess I haven't looked through the code, but the GREAT usefulness of this plugin deserves top marks. Well done!

01 Mar 2009 snowdeer Î

very nice code. thanks!

04 Aug 2009 Granzyme

Amazing function.
I had couple of questions Gus if you don't mind.
I am new to MATLAB (i'm a physician) and this is EXACTLY what I want - almost. I am trying to scroll through a whole stack of MRI images. So in order for this to work, I have to open lets say 25 seperate figure windows and then smoothly scroll through them. However - how can I just open ONE figure window and have ALL my images be scrolling through in it?

I am not much of a code write, but a nudge in the right direction will go a long way (meaning, i can use help function on MATLAB and attempt to write small code under your direction). Thanks!

07 Sep 2009 Torben Ellegaard Lund

Very nice idea Gus

I am struggling to find a way to make a scroll wheel modulate the frequency of a sound played by matlab. Would you happen to have an idea on how to proceed.

Best
Torben

27 Oct 2009 Eric Diaz

It would be nice if this worked with version 7.3.0 2006b, but, alas, it does not because as Matlab states..."There is no 'WindowScrollWheelFcn' property in the 'figure' class."

Is there any other solution?

28 Oct 2009 Eric Diaz

Below is my workaround for similar functionality, however, not with the mouse wheel but rather the keyboard arrows.

function [TF] = GTscroll2006b(event,fig)
% GTscroll2006b Use the scroll wheel to navigate figure windows
%
% function GTscroll2006b(event,fig)
%
% Example:
%
% for n=1:length(imgfiles);
% figure(100+n);
% set(gcf,'position',pos1,'windowStyle','docked')
% imagesc(im1(:,:,n),[0 max(max(im1(:,:,workingImage)))]);hold on;
% end
%
% TF=1
%
% while TF == 1
% event = getkey
% TF = GTscroll2006b(event,gcf)
% end
%
% ************** Requires getkey from FileExchange***********************
% http://www.mathworks.com/matlabcentral/fileexchange/7465-getkey
% ***********************************************************************
%
% Esdiaz - Oct 2009

%% Cycle through figures
CH = get(0,'children');

    H = sort(get(0,'children'));
    if event == 28 || event == 31 % left or down arrow = scroll down
        F = find(H<fig,1,'last');
    elseif event == 29 || event == 30 % up or right arrow = scroll up
        F = find(H>fig,1);
    elseif event == 13
        F=[];
    end
    
    if isempty(F),
        % jump to first or last figure
        if event == 28 || event == 31,
            figure(H(1));
            TF=1;
        elseif event == 29 || event == 30
            figure(H(end));
            TF=1;
        elseif event == 13
            TF=0;
        end;
    else
        % goto next figure
        figure(H(mod(F-1,length(H))+1));
        zoom;pause;
        TF=1;
    end;
%%
end

Please login to add a comment or rating.
Updates
03 Mar 2008

Spelling correction.

Tag Activity for this File
Tag Applied By Date/Time
gui tools Gus Brown 22 Oct 2008 09:42:24
example Gus Brown 22 Oct 2008 09:42:24
mouse scroll wheel Gus Brown 22 Oct 2008 09:42:24
mouse scroll wheel Don Orofino 20 Oct 2009 09:23:59

Contact us at files@mathworks.com