Way to get handle to just brushed object?

조회 수: 3 (최근 30일)
David Goldsmith
David Goldsmith 2011년 4월 15일
Hi! I have a method which catches the windowButtonUp event when brushing. I'd like to use the handle to the plot object (i.e., not the axes it's a child of, but the line or surface object itself) that was just brushed, but I can't find how to retrieve it. I wrote some code to try to do it, but it behaves inconsistently; before I try further to debug it, I'd like to know that I'm not re-inventing the wheel: is there a convenient way of retrieving the handle to a just-brushed object? Thanks!

채택된 답변

Sarah Wait Zaranek
Sarah Wait Zaranek 2011년 4월 26일
Not sure if this is what you are doing or not, but this seems to work for me. It works very nicely on lines (at least in my limited testing)
% find all objects with the property BrushData
hB = findobj(gcf,'-property','BrushData');
% extract the brush data
data = get(hB,'BrushData');
% find objects where BrushData is not all zeros (i.e. you have some points "brushed"). Note: this probably could be written in a cleaner fashion, but it shows you the idea. Then, index back into your list of objects and get the ones that were "brushed"
brushObj = hB(find(cellfun(@(x) sum(x),data)))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interaction Control에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by