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 Tracking in figure with regular uipanels and javapanels

Subject: Mouse Tracking in figure with regular uipanels and javapanels

From: Frank

Date: 20 Jan, 2011 12:54:04

Message: 1 of 5

Hi there,

i want to record my mouse movement (and clicking) within a gui and save the coordinates in a specific file or matrix. Later on i want to use these coordinates with the jmouseemu function by Takeshi Ikuma. (Thx to Yair Altman and his undocumented MATLAB site for explaining all the java things!!)

Thing is:
The recording of the coordinates works quite well using the simple WindowButtonMotionFcn of the figure as long as the figure is not using javatrees or uitables. As soon as i get over a javatree or a table inside my figure the WindowButtonMotionFcn doesnt seem to work anymore.

Short example: Simple Figure with uitable and activated WindowButtonMotionFcn to disp the position of the mouse in the command screen

function mousetrack
hfig=figure('WindowButtonMotionFcn',@myCall);
htable=uitable(hfig,'Data',magic(10),'Position',[0 0 300 300]);

function myCall(hfig,event)
pos=get(hfig,'CurrentPoint')

As soon as u enter the area of the uitable the position flooding in the matlab command window stops.
I also tried various programms from the file exchange, but they seem to have the same problem eihter they need an axis handle or something else.
How can i get those positions anyway? Any hints?

Regards Frank

Subject: Mouse Tracking in figure with regular uipanels and javapanels

From: Yair Altman

Date: 20 Jan, 2011 19:15:05

Message: 2 of 5

"Frank" wrote in message <ih9b9c$2c9$1@fred.mathworks.com>...
> Hi there,
>
> i want to record my mouse movement (and clicking) within a gui and save the coordinates in a specific file or matrix. Later on i want to use these coordinates with the jmouseemu function by Takeshi Ikuma. (Thx to Yair Altman and his undocumented MATLAB site for explaining all the java things!!)
>
> Thing is:
> The recording of the coordinates works quite well using the simple WindowButtonMotionFcn of the figure as long as the figure is not using javatrees or uitables. As soon as i get over a javatree or a table inside my figure the WindowButtonMotionFcn doesnt seem to work anymore.


For Java components, you can simply set their MouseMovedCallback property:
http://UndocumentedMatlab.com/blog/uicontrol-callbacks/

Also related: http://UndocumentedMatlab.com/blog/undocumented-mouse-pointer-functions/

Yair Altman
http://UndocumentedMatlab.com

Subject: Mouse Tracking in figure with regular uipanels and javapanels

From: Frank

Date: 21 Jan, 2011 10:21:04

Message: 3 of 5

> For Java components, you can simply set their MouseMovedCallback property:
> http://UndocumentedMatlab.com/blog/uicontrol-callbacks/
>
> Also related: http://UndocumentedMatlab.com/blog/undocumented-mouse-pointer-functions/
>
> Yair Altman
> http://UndocumentedMatlab.com

For some reason i cant set the MouseMovedCallback for the whole uitable but just for parts of it.
set(htable.Table,'MouseMovedCallback',@myCall)
set(htable.TableScrollPane,'MouseMovedCallback',@myCall)
This just gives the effect that in some regions of the uitable the callback is still not executed.
What am i missing here?
get(htable) gives the info about my table but the MouseMovedCallback is missing..
whereas get(htable.Table) or get(htable.TableScrollPane) gives all the callbacks and options mentioned in your article.

Subject: Mouse Tracking in figure with regular uipanels and javapanels

From: matt dash

Date: 21 Jan, 2011 18:03:05

Message: 4 of 5

"Frank" wrote in message <ihbmmg$4h5$1@fred.mathworks.com>...
> > For Java components, you can simply set their MouseMovedCallback property:
> > http://UndocumentedMatlab.com/blog/uicontrol-callbacks/
> >
> > Also related: http://UndocumentedMatlab.com/blog/undocumented-mouse-pointer-functions/
> >
> > Yair Altman
> > http://UndocumentedMatlab.com
>
> For some reason i cant set the MouseMovedCallback for the whole uitable but just for parts of it.
> set(htable.Table,'MouseMovedCallback',@myCall)
> set(htable.TableScrollPane,'MouseMovedCallback',@myCall)
> This just gives the effect that in some regions of the uitable the callback is still not executed.
> What am i missing here?
> get(htable) gives the info about my table but the MouseMovedCallback is missing..
> whereas get(htable.Table) or get(htable.TableScrollPane) gives all the callbacks and options mentioned in your article.'

In which regions does it not execute? The column header and row header probably have their own MouseMovedCallbacks...

Subject: Mouse Tracking in figure with regular uipanels and javapanels

From: Frank

Date: 24 Jan, 2011 08:03:03

Message: 5 of 5

>
> In which regions does it not execute? The column header and row header probably have their own MouseMovedCallbacks...

Exactly, in the column header and row header it's not working so far.
Thing is: i dont want to set the callback for every single part but rather the whole table. Sort of setting the "parents" callback on my function

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