Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
mouse cursor coordinates

Subject: mouse cursor coordinates

From: muzaffar

Date: 30 Apr, 2008 14:11:03

Message: 1 of 11

Dear All,
I want to get coordinates of cursor movement.
please tell me some hint:
kind regards.

Subject: mouse cursor coordinates

From: Freelance Embedded Systems Engineer

Date: 30 Apr, 2008 14:55:43

Message: 2 of 11

muzaffar wrote:
> Dear All,
> I want to get coordinates of cursor movement.
> please tell me some hint:
> kind regards.
>

Muzaffar,

Try searching Google with the keywords "Matlab Mouse Coordinates"
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/ginput.html

Subject: mouse cursor coordinates

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 30 Apr, 2008 18:32:46

Message: 3 of 11

In article <fv9ulm$jmm$1@fred.mathworks.com>,
muzaffar <muzaffarbashir@yahoo.com> wrote:

>I want to get coordinates of cursor movement.
>please tell me some hint:

WindowButtonMotionFcn callback of a figure
or get(0,'CurrentPosition')
--
  "It is surprising what a man can do when he has to, and how
  little most men will do when they don't have to."
                                              -- Walter Linn

Subject: mouse cursor coordinates

From: muzaffar

Date: 2 May, 2008 14:14:05

Message: 4 of 11

Dear All,
I want to get values of mouse cursor coordinates, control
of left/right click and how i can get response of scroll
button?
kind regards..

"muzaffar " <muzaffarbashir@yahoo.com> wrote in message
<fv9ulm$jmm$1@fred.mathworks.com>...
> Dear All,
> I want to get coordinates of cursor movement.
> please tell me some hint:
> kind regards.
>

Subject: mouse cursor coordinates

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 2 May, 2008 15:53:42

Message: 5 of 11

In article <fvf7jc$5f2$1@fred.mathworks.com>,
muzaffar <muzaffarbashir@yahoo.com> wrote:

>I want to get values of mouse cursor coordinates,

As I answered you on Wednesday:

>>WindowButtonMotionFcn callback of a figure
>>or get(0,'CurrentPosition')

>control of left/right click

It depends what you mean by 'control'. There is the
WindowButtonDownFcn and WindowButtonUpFcn callback of a figure.
Most controls have a Callback callback when they are clicked.
Within a callback, you can determine which button was clicked
and whether any modifiers were applied by examining the figure's
SelectionType property.

However, there are situations where the right mouse button is
reserved for the context menu, and overriding that behaviour
(or creating your own context menu behaviours) is not easy.


>and how i can get response of scroll button?

Starting from R2007a (I think it is), you can set the figure
WindowScrollWheelFcn property.
--
  "All human knowledge takes the form of interpretation."
                                              -- Walter Benjamin

Subject: mouse cursor coordinates

From: someone

Date: 2 May, 2008 15:59:03

Message: 6 of 11

"muzaffar " <muzaffarbashir@yahoo.com> wrote in message
<fvf7jc$5f2$1@fred.mathworks.com>...
> Dear All,
> I want to get values of mouse cursor coordinates,
control
> of left/right click

See the SelectionType and WindowButtonMotionFcn
descriptions for the Figure Properties.

 and how i can get response of scroll
> button?


See the SliderStep description for the Uicontrol Properties


> kind regards..
>
> "muzaffar " <muzaffarbashir@yahoo.com> wrote in message
> <fv9ulm$jmm$1@fred.mathworks.com>...
> > Dear All,
> > I want to get coordinates of cursor movement.
> > please tell me some hint:
> > kind regards.
> >
>
 

Subject: mouse cursor coordinates

From: muzaffar

Date: 2 May, 2008 16:32:03

Message: 7 of 11

thanks for your reply and concern
Hi,
i am new in matlab this mouse programing things.
i want to know the status of left mouse button
something like
get(....) to see if left mouse is clicked?
then i want to save value of mouse scroll button into a
variable?
kind regards



roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fvfde6$bbq$1@canopus.cc.umanitoba.ca>...
> In article <fvf7jc$5f2$1@fred.mathworks.com>,
> muzaffar <muzaffarbashir@yahoo.com> wrote:
>
> >I want to get values of mouse cursor coordinates,
>
> As I answered you on Wednesday:
>
> >>WindowButtonMotionFcn callback of a figure
> >>or get(0,'CurrentPosition')
>
> >control of left/right click
>
> It depends what you mean by 'control'. There is the
> WindowButtonDownFcn and WindowButtonUpFcn callback of a
figure.
> Most controls have a Callback callback when they are
clicked.
> Within a callback, you can determine which button was
clicked
> and whether any modifiers were applied by examining the
figure's
> SelectionType property.
>
> However, there are situations where the right mouse
button is
> reserved for the context menu, and overriding that
behaviour
> (or creating your own context menu behaviours) is not
easy.
>
>
> >and how i can get response of scroll button?
>
> Starting from R2007a (I think it is), you can set the
figure
> WindowScrollWheelFcn property.
> --
> "All human knowledge takes the form of interpretation."
> -- Walter
Benjamin

Subject: mouse cursor coordinates

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 2 May, 2008 17:11:12

Message: 8 of 11

In article <fvffm3$cjr$1@fred.mathworks.com>,
muzaffar <muzaffarbashir@yahoo.com> wrote:

>i am new in matlab this mouse programing things.
>i want to know the status of left mouse button
>something like
>get(....) to see if left mouse is clicked?

Then you will have to go in at the java level.

However, you could use the WindowButtonDownFcn to set a global
variable to 1, and you could use the WindowButtonUpFcn to set
the global variable to 0. Then you could check the value of the
global variable to know whether the button is pressed.
In those callbacks, you would need to test the SelectionType
to see whether or not it was the left mouse button that was pressed
or a different mouse button or a modified mouse button (such as
shift-right-click).

>then i want to save value of mouse scroll button into a
>variable?

Use the WindowScrollWheelFcn callback, get the count from the
event structure, and store it in a global variable.


(In the places where I said 'global variable' above, there are
other ways that are better programming but take more experience
to use properly.)
--
  "Pray do not take the pains / To set me right. /
   In vain my faults ye quote; / I wrote as others wrote /
   On Sunium's hight." -- Walter Savage Landor

Subject: mouse cursor coordinates

From: muzaffar

Date: 2 May, 2008 18:50:21

Message: 9 of 11

Hi again.
could you please give me some more details how i can use it

"Use the WindowScrollWheelFcn callback, get the count from
the ...."
if i move scroll wheel up and down (at the same time )is
it possible to get its values in some variable.




roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fvfhvg$hkr$1@canopus.cc.umanitoba.ca>...
> In article <fvffm3$cjr$1@fred.mathworks.com>,
> muzaffar <muzaffarbashir@yahoo.com> wrote:
>
> >i am new in matlab this mouse programing things.
> >i want to know the status of left mouse button
> >something like
> >get(....) to see if left mouse is clicked?
>
> Then you will have to go in at the java level.
>
> However, you could use the WindowButtonDownFcn to set a
global
> variable to 1, and you could use the WindowButtonUpFcn
to set
> the global variable to 0. Then you could check the value
of the
> global variable to know whether the button is pressed.
> In those callbacks, you would need to test the
SelectionType
> to see whether or not it was the left mouse button that
was pressed
> or a different mouse button or a modified mouse button
(such as
> shift-right-click).
>
> >then i want to save value of mouse scroll button into a
> >variable?
>
> Use the WindowScrollWheelFcn callback, get the count
from the
> event structure, and store it in a global variable.
>
>
> (In the places where I said 'global variable' above,
there are
> other ways that are better programming but take more
experience
> to use properly.)
> --
> "Pray do not take the pains / To set me right. /
> In vain my faults ye quote; / I wrote as others
wrote /
> On Sunium's hight." -- Walter
Savage Landor

Subject: mouse cursor coordinates

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 2 May, 2008 19:55:49

Message: 10 of 11

In article <fvfnpd$rcl$1@fred.mathworks.com>,
muzaffar <muzaffarbashir@yahoo.com> wrote:

>could you please give me some more details how i can use it

>"Use the WindowScrollWheelFcn callback, get the count from
>the ...."
>if i move scroll wheel up and down (at the same time )is
>it possible to get its values in some variable.

You can't move the scroll wheel up and down *at the same time*,
unless you are referring to different axes (e.g., that you
mean "rotate counter-clockwise" when you say "up", and
you mean "press vertically to click the middle button" when you say "down".)

As far as Matlab is concerned, at any instant, the scroll wheel
either stays the same, rotates forward one "click", or rotates
backwards one "click". Matlab increments a counter for each "forward"
(clockwise, "down") click, and decrements a counter for each "backwards"
(counter-clockwise, "up") click, so when the counter is fetched it
represents the net rotation since the counter was last cleared.

For more information, see the Matlab documentation on Figure Properties,

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/figure_props.html

and search about 80% of the way through the page to the description
of WindowScrollWheelFcn

For more information on creating callbacks,

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f16-999606.html
--
   "No one has the right to destroy another person's belief by
   demanding empirical evidence." -- Ann Landers

Subject: mouse cursor coordinates

From: muzaffar

Date: 5 May, 2008 14:18:03

Message: 11 of 11

thanks for the email and concern.
could you 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





roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fvfrk5$1tt$1@canopus.cc.umanitoba.ca>...
> In article <fvfnpd$rcl$1@fred.mathworks.com>,
> muzaffar <muzaffarbashir@yahoo.com> wrote:
>
> >could you please give me some more details how i can
use it
>
> >"Use the WindowScrollWheelFcn callback, get the count
from
> >the ...."
> >if i move scroll wheel up and down (at the same time )
is
> >it possible to get its values in some variable.
>
> You can't move the scroll wheel up and down *at the same
time*,
> unless you are referring to different axes (e.g., that
you
> mean "rotate counter-clockwise" when you say "up", and
> you mean "press vertically to click the middle button"
when you say "down".)
>
> As far as Matlab is concerned, at any instant, the
scroll wheel
> either stays the same, rotates forward one "click", or
rotates
> backwards one "click". Matlab increments a counter for
each "forward"
> (clockwise, "down") click, and decrements a counter for
each "backwards"
> (counter-clockwise, "up") click, so when the counter is
fetched it
> represents the net rotation since the counter was last
cleared.
>
> For more information, see the Matlab documentation on
Figure Properties,
>
>
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/f
igure_props.html
>
> and search about 80% of the way through the page to the
description
> of WindowScrollWheelFcn
>
> For more information on creating callbacks,
>
>
http://www.mathworks.com/access/helpdesk/help/techdoc/creat
ing_guis/f16-999606.html
> --
> "No one has the right to destroy another person's
belief by
> demanding empirical evidence." -- Ann
Landers

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us