Add a callback function for impoint object
이전 댓글 표시
I have a GUI where the user uses impoint to add points to the axes. Whenever an impoint object is created, I want to add a callback function that is called whenever the point is dragged. I also want several inputs to be passed to the callback function. How do I do this?
I think this uses iptaddcallback(h,callback,func_handle), but I can't figure out how to pass inputs to the function handle, or what to use for the 'callback' property. New to Matlab here :P Any help would be great, thanks!
답변 (2개)
Sean de Wolski
2012년 8월 1일
편집: Sean de Wolski
2012년 8월 8일
Sounds like you will want to use its 'addNewPositionCallback' function.
More
I think you can pass it the typical way using a cell array that contains the function handle and additional inputs. E.g:
h = figure;
f = @(src,evt,x) disp(x);
x = 'pi';
iptaddcallback(h, 'WindowButtonMotionFcn', {f,x});
댓글 수: 4
JM
2012년 8월 1일
Image Analyst
2012년 8월 1일
What additional variables do you need access to?
JM
2012년 8월 7일
Sean de Wolski
2012년 8월 8일
See More
Image Analyst
2012년 8월 1일
0 개 추천
What is the use case for this? I don't understand why every point has to have its own individual callback? Are you sure you don't just want the user to click several points and then you run some function when they're done clicking on points?
댓글 수: 2
JM
2012년 8월 1일
Image Analyst
2012년 8월 1일
What would you do in the callback? Anyway, can't you just call ginput and then put whatever code it is that you want to run right after ginput returns with the coordinate? That's how I would approach it because it seems a lot easier.
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!