필터 지우기
필터 지우기

app designer mouse events (position and clicks) on axes component

조회 수: 91 (최근 30일)
bobby27
bobby27 2018년 8월 16일
댓글: Matteo Verardo 2023년 8월 2일
I am working on an app with that i want to move drawn objects on an axes element. Something like in this video.
As a first step i want to know the coordinates of the mouse on the axes and want to detect the mouse clicks the user does on this field. Ive been reading the forums for a while but i had no success so far creating a working program.
For testing purposes I created an application in App designer with an axes, two edit fields(numeric) and one lamp components.
The Edit Fields are supposed to show the actual coordinates of the mouse while the lamp lights up when the button is pressed. The main window looks like this:
I have collected some information about how im supposed to do but altogether im still lost.
First part of the code im trying to use:
function mouseMove(objectHandle, eventData)
cursorPoint = get(objectHandle.axes1, 'CurrentPoint');
app.xCoord.Value = cursorPoint(1,1);
app.yCoord.Value = cursorPoint(1,2);
end
Second part:
set(gca, 'WindowButtonMotionFcn', @mouseMove);
Since i havent seen a working application with mouse events, only some code parts from similar projects on the forums, im not sure if it could work at all, or where im supposed to put this code lines in the App Designer code.
I uploaded the app if someone would look into that. Any information on where to start with mouse events/ written or video guides / a working code for my test application would be greatly appreciated.
  댓글 수: 2
Adam
Adam 2018년 8월 16일
Unfortunately I don't think mouse interactivity is supported yet by App designer - one of the many reasons I do not use it yet.
gives details of what is not yet supported, with links to help for earlier versions too to show what they supported.
Lucas Acuna Scafati
Lucas Acuna Scafati 2020년 5월 8일
Were you able to find a solution to this issue? I currently working with 2017b and have the same problem.

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

답변 (1개)

Sampath Rachumallu
Sampath Rachumallu 2020년 4월 28일
편집: Sampath Rachumallu 2020년 4월 28일
Create a function called 'mouseMove' inside app in your case. Refer
for creating a function inside an app.Next, Create a Startup function for the app. Refer the below link on how to add startup function for the app:
Finally set the mouse motion function callback to function 'mouseMove' inside startup function
Note: I am using 2019a and Mouse callbacks are supported in this version.
%In startup function
function startupFcn(app)
%set WindowButtonMotionFcn as mouse move function
set(app.UIFigure, 'WindowButtonMotionFcn', @mouseMove);
end
  댓글 수: 1
Matteo Verardo
Matteo Verardo 2023년 8월 2일
@app.mouseMove not @mouseMove
function mouseMove(app, scr, event)
//the code
end

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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by