mouse scroll wheel

Discussion in 'MATLAB' started by muzaffar, May 6, 2008.

  1. muzaffar

    muzaffar Guest

    hi everybody
    could some one please tell me why i am unable to get
    values for
    variable outdd? in the following program.
    i can get and plot scroll wheel up/down movement with time
    let say but i am unable to get array values in the end.
    plz use hold on at command line after calling to the
    function below.


    function outdd= scroll_wheel12()
    % Illustrates how to use WindowScrollWheelFcn property
    %f = %e 'WindowScrollWheelFcn'
    global dd
    set(gcf,'WindowScrollWheelFcn',@figScroll);


    x = [0:.1:40];
    y = 4.*cos(x)./(x+2);
    a = axes;
    h = plot(x,y);

    title('Rotate the scroll wheel')
    var12=0;
    tv12=1;
    function figScroll(src,evnt)

    if evnt.VerticalScrollCount > 0
    var12=var12+1;
    tt(tv12)=tv12;
    xv12(tv12)=var12;

    elseif evnt.VerticalScrollCount < 0
    var12=var12-1;
    tt(tv12)=tv12;
    xv12(tv12)=var12;

    end

    disp('time')
    disp(tv12)
    disp('value')
    disp(var12)
    %outdd=[tv12 var12];
    dd=[tt; xv12];
    plot(tt,xv12,'*')
    tv12=tv12+1;

    end %figScroll
    % disp(eventdata.scrdata)

    disp(var12)
    % outdd=[tv12 var12];
    outdd=dd;

    end % scroll_wheel
     
    muzaffar, May 6, 2008
    #1
    1. Advertisements

  2. muzaffar

    matt dash Guest


    The problem is that the line "outdd=dd" runs as soon as you
    run the main function, and does not wait for the user to
    scroll the wheel. Try instead adding a similar line to the
    figScroll function, since this is what runs when the user
    moves the mouse wheel. (You will need to figure out how to
    get the value back to the command window or wherever you
    want it though... how you do that depends on when/where you
    want to access this value)
     
    matt dash, May 6, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.