필터 지우기
필터 지우기

Matlab 'get' function and detecting user mouse click

조회 수: 42 (최근 30일)
Brandon
Brandon 2014년 7월 19일
댓글: Doli Swey 2021년 3월 5일
I am using the get function to retrieve the mouse position like this:
get(0,'PointerLocation');
I also need to detect when a mouse button has been clicked. I've tried searching everywhere I know to search for this and cannot find how to do it. I also can't really find everything the get function can do (such as PointerLocation or ScreenSize, etc).
I'm using the java robot in other places in my code to move the mouse and get screen pixel colors. Is there any java functionality that will detect mouse clicks? Is there good documentation on what other java functionality there is for matlab and how to use it (syntax)?
Thanks in advance
  댓글 수: 1
Doli Swey
Doli Swey 2021년 3월 5일
Hi Brandon, did you find the answer? I am looking exactly same thing ...

댓글을 달려면 로그인하십시오.

답변 (1개)

Dasharath Gulvady
Dasharath Gulvady 2014년 8월 5일
편집: Dasharath Gulvady 2014년 8월 5일
Brandon, This can be achieved using 'WindowButtonDownFcn' property of the figure object.
Here is a demo code for the same:
function demo()
figure('WindowButtonDownFcn',@callBack)
function callBack(hObject,~)
mousePos=get(hObject,'CurrentPoint');
disp(['You clicked X:',num2str(mousePos(1)),', Y:',num2str(mousePos(2))]);
Hope this helps!
  댓글 수: 2
Brandon
Brandon 2014년 8월 7일
That works nicely, but I need this to work in another window outside of Matlab. Can this work like that with a modification or is there any other way to do it?
Dasharath Gulvady
Dasharath Gulvady 2014년 8월 7일
what exactly do you mean by "another window outside of Matlab"?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by