# HG changeset patch # User Rik # Date 1489381561 25200 # Node ID cc9dcadcef6bb205f714db7d94d2a541a10e2e69 # Parent 79122fab82ee9cce288257ce143767f5a406c90f Only return a handle from ui* functions if nargout > 0 (bug #49751). * uicontrol.m, uipanel.m, uipushtool.m, uiresume.m, uitoggletool.m, uitoolbar.m: Capture handle of newly created object in htmp and assign to output only if nargout > 0. Update docstrings to show calling convention. diff -r 79122fab82ee -r cc9dcadcef6b scripts/gui/uicontrol.m --- a/scripts/gui/uicontrol.m Sun Mar 12 19:12:27 2017 -0700 +++ b/scripts/gui/uicontrol.m Sun Mar 12 22:06:01 2017 -0700 @@ -107,6 +107,10 @@ [h, args] = __uiobject_split_args__ ("uicontrol", varargin, {"figure", "uipanel", "uibuttongroup"}); - hui = __go_uicontrol__ (h, args{:}); + htmp = __go_uicontrol__ (h, args{:}); + if (nargout > 0) + hui = htmp; + endif + endfunction diff -r 79122fab82ee -r cc9dcadcef6b scripts/gui/uipanel.m --- a/scripts/gui/uipanel.m Sun Mar 12 19:12:27 2017 -0700 +++ b/scripts/gui/uipanel.m Sun Mar 12 22:06:01 2017 -0700 @@ -17,10 +17,11 @@ ## . ## -*- texinfo -*- -## @deftypefn {} {@var{hui} =} uipanel (@var{property}, @var{value}, @dots{}) -## @deftypefnx {} {@var{hui} =} uipanel (@var{parent}, "@var{property}, @var{value}, @dots{}) +## @deftypefn {} {} uipanel (@var{property}, @var{value}, @dots{}) +## @deftypefnx {} {} uipanel (@var{parent}, "@var{property}, @var{value}, @dots{}) +## @deftypefnx {} {@var{hui} =} uipanel (@dots{}) ## -## Create a uipanel object and return a handle to it. +## Create a uipanel object. ## ## uipanels are used as containers to group other uicontrol objects. ## @@ -34,6 +35,9 @@ ## ## Uipanel properties are documented at @ref{Uipanel Properties}. ## +## The optional return value @var{hui} is a graphics handle to the created +## uipanel object. +## ## Examples: ## ## @example @@ -57,6 +61,10 @@ [h, args] = __uiobject_split_args__ ("uipanel", varargin, {"figure", "uipanel", "uibuttongroup"}); - hui = __go_uipanel__ (h, args{:}); + htmp = __go_uipanel__ (h, args{:}); + + if (nargout > 0) + hui = htmp; + endif endfunction diff -r 79122fab82ee -r cc9dcadcef6b scripts/gui/uipushtool.m --- a/scripts/gui/uipushtool.m Sun Mar 12 19:12:27 2017 -0700 +++ b/scripts/gui/uipushtool.m Sun Mar 12 22:06:01 2017 -0700 @@ -17,10 +17,11 @@ ## . ## -*- texinfo -*- -## @deftypefn {} {@var{hui} =} uipushtool (@var{property}, @var{value}, @dots{}) -## @deftypefnx {} {@var{hui} =} uipushtool (@var{parent}, @var{property}, @var{value}, @dots{}) +## @deftypefn {} {} uipushtool (@var{property}, @var{value}, @dots{}) +## @deftypefnx {} {} uipushtool (@var{parent}, @var{property}, @var{value}, @dots{}) +## @deftypefnx {} {@var{hui} =} uipushtool (@dots{}) ## -## Create a uipushtool object and return a handle to it. +## Create a uipushtool object. ## ## uipushtools are buttons that appear on a figure toolbar. The button is ## created with a border that is shown when the user hovers over the button. @@ -39,6 +40,9 @@ ## ## Uipushtool properties are documented at @ref{Uipushtool Properties}. ## +## The optional return value @var{hui} is a graphics handle to the created +## uipushobject object. +## ## Examples: ## ## @example @@ -70,6 +74,11 @@ h = h(1); endif endif - hui = __go_uipushtool__ (h, args{:}); + + htmp = __go_uipushtool__ (h, args{:}); + + if (nargout > 0) + hui = htmp; + endif endfunction diff -r 79122fab82ee -r cc9dcadcef6b scripts/gui/uiresume.m --- a/scripts/gui/uiresume.m Sun Mar 12 19:12:27 2017 -0700 +++ b/scripts/gui/uiresume.m Sun Mar 12 22:06:01 2017 -0700 @@ -30,6 +30,10 @@ function uiresume (h) + if (nargin < 1) + h = gcf (); + endif + if (! isfigure (h)) error ("uiresume: invalid figure handle H"); endif diff -r 79122fab82ee -r cc9dcadcef6b scripts/gui/uitoggletool.m --- a/scripts/gui/uitoggletool.m Sun Mar 12 19:12:27 2017 -0700 +++ b/scripts/gui/uitoggletool.m Sun Mar 12 22:06:01 2017 -0700 @@ -17,10 +17,11 @@ ## . ## -*- texinfo -*- -## @deftypefn {} {@var{hui} =} uitoggletool (@var{property}, @var{value}, @dots{}) -## @deftypefnx {} {@var{hui} =} uitoggletool (@var{parent}, @var{property}, @var{value}, @dots{}) +## @deftypefn {} {} uitoggletool (@var{property}, @var{value}, @dots{}) +## @deftypefnx {} {} uitoggletool (@var{parent}, @var{property}, @var{value}, @dots{}) +## @deftypefnx {} {@var{hui} =} uitoggletool (@dots{}) ## -## Create a uitoggletool object and return a handle to it. +## Create a uitoggletool object. ## ## uitoggletool are togglebuttons that appear on a figure toolbar. The ## button is created with a border that is shown when the user hovers over @@ -39,6 +40,9 @@ ## ## Uitoggletool properties are documented at @ref{Uitoggletool Properties}. ## +## The optional return value @var{hui} is a graphics handle to the created +## uitoggletool object. +## ## Examples: ## ## @example @@ -70,6 +74,11 @@ h = h(1); endif endif - hui = __go_uitoggletool__ (h, args{:}); + + htmp = __go_uitoggletool__ (h, args{:}); + + if (nargout > 0) + hui = htmp; + endif endfunction diff -r 79122fab82ee -r cc9dcadcef6b scripts/gui/uitoolbar.m --- a/scripts/gui/uitoolbar.m Sun Mar 12 19:12:27 2017 -0700 +++ b/scripts/gui/uitoolbar.m Sun Mar 12 22:06:01 2017 -0700 @@ -17,11 +17,12 @@ ## . ## -*- texinfo -*- -## @deftypefn {} {@var{hui} =} uitoolbar (@var{property}, @var{value}, @dots{}) -## @deftypefnx {} {@var{hui} =} uitoolbar (@var{parent}, @var{property}, @var{value}, @dots{}) +## @deftypefn {} {} uitoolbar (@var{property}, @var{value}, @dots{}) +## @deftypefnx {} {} uitoolbar (@var{parent}, @var{property}, @var{value}, @dots{}) +## @deftypefnx {} {@var{hui} =} uitoolbar (@dots{}) ## -## Create a uitoolbar object and return a handle to it. A uitoolbar displays -## uitoggletool and uipushtool buttons. +## Create a uitoolbar object. A uitoolbar displays uitoggletool and uipushtool +## buttons. ## ## If @var{parent} is omitted then a uitoolbar for the current figure is ## created. If no figure is available, a new figure is created first. @@ -34,6 +35,9 @@ ## ## Uitoolbar properties are documented at @ref{Uitoolbar Properties}. ## +## The optional return value @var{hui} is a graphics handle to the created +## uitoolbar object. +## ## Examples: ## ## @example @@ -52,6 +56,11 @@ function hui = uitoolbar (varargin) [h, args] = __uiobject_split_args__ ("uitoolbar", varargin, {"figure"}); - hui = __go_uitoolbar__ (h, args{:}); + + htmp = __go_uitoolbar__ (h, args{:}); + + if (nargout > 0) + hui = htmp; + endif endfunction