getting the ID of the line which just has been clicked on

조회 수: 3 (최근 30일)
Nikolaus
Nikolaus 2013년 10월 18일
댓글: Nikolaus 2013년 10월 18일
hi,
I have a varying set of lines which shall be displayed. Clicking on one of the lines some actions have to be performed which are specific for that line, i.e every line has its own set of actions. The lines are painted by h(i) = imline(parent, pos(i)); Now I need one callback function which is called whenevery one of the lines has been clicked on. And this callback function should tell me which of the lines has been clicked on. With this information I would be happy and could program the necesary specific actions.
How can I do that?
Nikolaus

답변 (1개)

Jeremy
Jeremy 2013년 10월 18일
I don't use the IP toolbox but I assuming you would be able to use a "line" instead of imline since I don't think imline has callback, or maybe this could be adapted to imline.
function []=xxx;
figure;
line([1 0], [1 0], 'ButtonDownFcn',{@line_click,1});
line([0 1], [1 0], 'ButtonDownFcn',{@line_click,2});
function line_click(src,evnt,l)
msgbox(num2str(l));

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by