|
From: | Ben Abbott |
Subject: | Re: [new function/changeset] thought/request for ishandle() |
Date: | Tue, 14 Oct 2008 08:05:52 -0400 |
On Oct 14, 2008, at 3:50 AM, Michael Goffioul wrote:
On Tue, Oct 14, 2008 at 4:18 AM, Ben Abbott <address@hidden> wrote:Please consider the attached changeset for the new function ishandle_with_props(). ishandle_with_prop (h, "prop1", value1, "prop2", value2, ...)My intent is that it be used to verify axes handles. I'm prepared to applyit to the existing m-files provided it is accepted. The files I'veidentified as the present are: axes.m , cla.m, colorbar.m, comet.m, hold.m,plotmatrix.m, plotyy.m, & colorbar.m.With the exception of colorbar() which looks for an image handle, the others seek an axes handle. In the case of plotyy looking for an axes handle with aspecific "position" would be useful.Isn't this redundant with findobj using 'flat' argument? Basically ishandle_with_prop (h, "prop1", value1, "prop2", value2, ...) is the same asishandle(h) && findobj(h, "flat", "prop1", value1, "prop2", value2, ...)Michael.
If "h" is a vector, then things get a bit more complicated. However, using findobj certainly has advantages over what I had done.
For scalar "h" props = { "prop1", value1, "prop2", value2, ... } ishandle(h) && findobj(h, "flat", props{:}) == h For vector "h" ishandle(h) & ismember (h, findobj (h,"flat", props{:})); Which would reduce my function to the trivial ... function [ ret ] = ishandle_with_props (h, varargin)ret = (ishandle (h) & ismember (h, findobj (h, "flat", varargin{:})));
endfunctionThe isfigure() and ishghandle() functions are quite similar. I like those as they make the m-file if-blocks easier to read. For that reason I was looking for a similar funcition for axes, but wanted to include additional information, and decided to try to float a version of ishande() with properties specified.
In any event, would an isaxes() is a better choice? Ben
[Prev in Thread] | Current Thread | [Next in Thread] |