# HG changeset patch # User Rik # Date 1664995985 25200 # Node ID 5f7d5934a1a9739426bcfa175e8519edf0200cdb # Parent c5c8bf50449c97974f1a44ac08fced217a049aed gco.m: Extend function to accept a figure handle input (bug #63161) * gco.m: Rename allowable input to "hfig" in documentation. Change function prototype to accept single input "hfig". Add input validation code for optional input hfig. Add BIST test for input validation. diff -r c5c8bf50449c -r 5f7d5934a1a9 scripts/plot/util/gco.m --- a/scripts/plot/util/gco.m Wed Oct 05 10:35:31 2022 -0400 +++ b/scripts/plot/util/gco.m Wed Oct 05 11:53:05 2022 -0700 @@ -25,9 +25,9 @@ ## -*- texinfo -*- ## @deftypefn {} {@var{h} =} gco () -## @deftypefnx {} {@var{h} =} gco (@var{fig}) +## @deftypefnx {} {@var{h} =} gco (@var{hfig}) ## Return a handle to the current object of the current figure, or a handle -## to the current object of the figure with handle @var{fig}. +## to the current object of the figure with handle @var{hfig}. ## ## The current object of a figure is the object that was last clicked on. It ## is stored in the @qcode{"CurrentObject"} property of the target figure. @@ -46,8 +46,20 @@ ## @seealso{gcbo, gca, gcf, gcbf, get, set} ## @end deftypefn -function h = gco () +function h = gco (hfig) - h = get (get (0, "currentfigure"), "currentobject"); + if (nargin == 1) + if (! isfigure (hfig)) + error ("gco: HFIG must be a graphics handle to a figure object"); + endif + else + hfig = get (0, "currentfigure"); + endif + + h = get (hfig, "currentobject"); endfunction + + +## Test input invalidation +%!error gco (-1)