Way to get handle to just brushed object?

11 次查看(过去 30 天)
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