필터 지우기
필터 지우기

Create a "listener" to a slider

조회 수: 3 (최근 30일)
Gabriel
Gabriel 2016년 6월 22일
댓글: Walter Roberson 2016년 6월 24일
I am creating a GUI in which I display a 3D image and navigate through it using a slider. I want to draw some points (using a "WindowButtonDownFcn" callback, i.e., I do not have any information about the position of the slider once I call the drawing function) over a certain slice using the mouse and that point should appear over all other slices and be editable as soon as the user uses the slider to switch between slices.
One possible solution that came to my mind is use "listeners", so whenever the user moves the slider, my drawing function is notified and the slider position is passed to it. . Following the MATLAB tutorial, I defined my classes so I can include the listener to my code, but it is not working. . How can I implement this functionality?
Thank you all in advance,

답변 (2개)

Steven Lord
Steven Lord 2016년 6월 22일
Use the slider's Callback property to call the function that draws or updates the view.
  댓글 수: 1
Gabriel
Gabriel 2016년 6월 23일
I already do that. The point is: once I call the drawing function, I can't access the value of the slider so I can plot at the moment the user changes the slice using the slide bar. Only when the user hits "RETURN" and the control goes back to the main window (where the slider is placed).

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


Walter Roberson
Walter Roberson 2016년 6월 22일
The WindowButtonDownFcn can fetch the Value property of the slider as needed.
  댓글 수: 3
Steven Lord
Steven Lord 2016년 6월 23일
As long as your drawing function has access to the slider's handle, it most certainly can retrieve the slider's properties.
Walter Roberson
Walter Roberson 2016년 6월 24일
Right, you just need the handle. If you are using GUIDE and the slider was created as part of the .fig then the handle will be available in the handles structure. If you are not using GUIDE or you are creating the slider at run time then see

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by