annotate scripts/gui/uibuttongroup.m @ 27730:5b9067c17e4b

Keep track of children in uibuttongroup (bug #55230). * graphics.in.h (uibuttongroup::properties::adopt, uibuttongroup::properties::remove_child): Add new functions. * graphics.cc (uicontrol::properties::set_style, uibuttongroup::properties::adopt, uibuttongroup::properties::remove_child): Update "selectedobject" and "value". * uibuttongroup.m: Make the demo resizable. Add BISTs for programmatic interaction.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 15 Dec 2018 12:53:18 +0100
parents 83774c2a1b92
children b442ec6dda5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25298
diff changeset
1 ## Copyright (C) 2016-2019 Andrew Thornton
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
2 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
3 ## This file is part of Octave.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24478
diff changeset
5 ## Octave is free software: you can redistribute it and/or modify it
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24478
diff changeset
7 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 21824
diff changeset
8 ## (at your option) any later version.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
9 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 21824
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 21824
diff changeset
13 ## GNU General Public License for more details.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
14 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24478
diff changeset
17 ## <https://www.gnu.org/licenses/>.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
18
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
19 ## -*- texinfo -*-
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
20 ## @deftypefn {} {@var{hui} =} uibuttongroup (@var{property}, @var{value}, @dots{})
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
21 ## @deftypefnx {} {@var{hui} =} uibuttongroup (@var{parent}, @var{property}, @var{value}, @dots{})
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
22 ## @deftypefnx {} {} uibuttongroup (@var{h})
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
23 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
24 ## Create a uibuttongroup object and return a handle to it.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
25 ##
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
26 ## A uibuttongroup is used to group uicontrol objects.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
27 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
28 ## If @var{parent} is omitted then a uibuttongroup for the current figure is
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
29 ## created. If no figure is available, a new figure is created first.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
30 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
31 ## If @var{parent} is given then a uibuttongroup relative to @var{parent} is
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
32 ## created.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
33 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
34 ## Any provided property value pairs will override the default values of the
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
35 ## created uibuttongroup object.
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
36 ##
26877
83774c2a1b92 doc: Place cross-reference from list of graphics object properties back to object (bug #46076).
Rik <rik@octave.org>
parents: 26376
diff changeset
37 ## The full list of properties is documented at @ref{Uibuttongroup Properties}.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
38 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
39 ## Examples:
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
40 ##
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
41 ## @example
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
42 ## @group
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
43 ## ## Create figure and panel on it
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
44 ## f = figure;
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
45 ## ## Create a button group
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
46 ## gp = uibuttongroup (f, "Position", [ 0 0.5 1 1])
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
47 ## ## Create a buttons in the group
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
48 ## b1 = uicontrol (gp, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
49 ## "string", "Choice 1", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
50 ## "Position", [ 10 150 100 50 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
51 ## b2 = uicontrol (gp, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
52 ## "string", "Choice 2", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
53 ## "Position", [ 10 50 100 30 ]);
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
54 ## ## Create a button not in the group
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
55 ## b3 = uicontrol (f, "style", "radiobutton", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
56 ## "string", "Not in the group", ...
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
57 ## "Position", [ 10 50 100 50 ]);
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
58 ## @end group
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
59 ## @end example
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
60 ##
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
61 ## When called with a single argument @var{h} which is a handle to an existing
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
62 ## uibuttongroup object, switch the focus to the specified uibuttongroup. This
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
63 ## functionality is not currently implemented.
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
64 ## @seealso{figure, uipanel}
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
65 ## @end deftypefn
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
66
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
67 ## Author: zeripath
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
68
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
69 function hui = uibuttongroup (varargin)
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
70
24478
59041be1994b Use new function isgraphics to simplify m-files.
Rik <rik@octave.org>
parents: 24423
diff changeset
71 if (nargin == 1 && isgraphics (varargin{1}, "uibuttongroup"))
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
72 warning ("uibuttongroup: focusing not implemented yet");
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
73 return;
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
74 endif
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
75
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
76 [h, args] = __uiobject_split_args__ ("uibuttongroup", varargin,
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
77 {"figure", "uipanel", "uibuttongroup"});
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
78 hui = __go_uibuttongroup__ (h, args{:});
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
79
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
80 endfunction
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
81
25298
5ca8abb27644 Only emit a warning, not error, when uiXXX.m are called for focusing (bug #53710).
Rik <rik@octave.org>
parents: 25054
diff changeset
82
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
83 %!demo
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
84 %! f = clf ();
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
85 %! gp = uibuttongroup (f, "position", [0 0.5 1 0.5], ...
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
86 %! "selectionchangedfcn", ...
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
87 %! @(h, e) fprintf ("Selection changed: %s\n", get (e.NewValue, "string")));
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
88 %! b1 = uicontrol (gp, "style", "radiobutton", ...
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
89 %! "string", "Choice 1", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
90 %! "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
91 %! "position", [0.01 0.5 0.98 0.5]);
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
92 %! b2 = uicontrol (gp, "style", "radiobutton", ...
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
93 %! "string", "Choice 2", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
94 %! "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
95 %! "position", [0.01 0 0.98 0.5]);
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
96 %! b3 = uicontrol (f, "style", "radiobutton", ...
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
97 %! "string", "Not in the group", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
98 %! "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
99 %! "position", [ 0.01 0 0.98 0.5 ]);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
100 %! fprintf ("Current selected: %s\n", get (get (gp, "selectedobject"), "string"));
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
101 %! pause (0.5);
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
102 %! disp ("Select b2");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
103 %! set (gp, "selectedobject", b2);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
104 %! fprintf ("Current selected: %s\n", get (get (gp, "selectedobject"), "string"));
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
105 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
106 %! disp ("Select None");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
107 %! set (gp, "selectedobject", []);
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
108 %! pause (0.1);
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
109 %! fprintf ("Current selected: %s\n", get (get (gp, "selectedobject"), "string"));
21824
6780a8657be3 Implement uibuttongroup (bug #47513)
Andrew Thornton <art27@cantab.net>
parents:
diff changeset
110
27730
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
111 ## Test mutual selection logic for radiobuttons
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
112 ## FIXME: commented out until a test can be found that doesn't rely on
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
113 ## long values for pause() which still can occasionally fail.
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
114 %!#test <*55230>
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
115 %! hf = figure ("visible", "off");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
116 %! unwind_protect
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
117 %! bg = uibuttongroup (hf);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
118 %! b1 = uicontrol (bg, "style", "radiobutton", "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
119 %! "position", [0, 0, 1, 0.5]);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
120 %! b2 = uicontrol (bg, "style", "radiobutton", "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
121 %! "position", [0, 0.5, 1, 0.5]);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
122 %! assert (get (bg, "selectedobject"), b1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
123 %! assert (get (b1, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
124 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
125 %! ## select radiobutton 2
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
126 %! set (bg, "selectedobject", b2);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
127 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
128 %! assert (get (b1, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
129 %! assert (get (b2, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
130 %! ## set radiobutton 1
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
131 %! set (b1, "value", 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
132 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
133 %! assert (get (bg, "selectedobject"), b1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
134 %! assert (get (b1, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
135 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
136 %! ## unset all radiobuttons
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
137 %! set (bg, "selectedobject", []);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
138 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
139 %! assert (get (b1, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
140 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
141 %! ## change style of selected button
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
142 %! set (b1, "value", 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
143 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
144 %! assert (get (bg, "selectedobject"), b1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
145 %! set (b1, "style", "pushbutton");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
146 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
147 %! assert (get (bg, "selectedobject"), []);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
148 %! ## add new button
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
149 %! b3 = uicontrol (bg, "style", "togglebutton");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
150 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
151 %! assert (get (bg, "selectedobject"), b3);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
152 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
153 %! assert (get (b3, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
154 %! ## remove selected button
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
155 %! delete (b3);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
156 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
157 %! assert (get (bg, "selectedobject"), []);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
158 %! unwind_protect_cleanup
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
159 %! close (hf);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
160 %! end_unwind_protect
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
161
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
162 ## Test mutual selection logic for togglebuttons
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
163 ## FIXME: commented out until a test can be found that doesn't rely on
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
164 ## long values for pause() which still can occasionally fail.
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
165 %!#test <*55230>
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
166 %! hf = figure ("visible", "off");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
167 %! unwind_protect
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
168 %! bg = uibuttongroup (hf);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
169 %! b1 = uicontrol (bg, "style", "togglebutton", "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
170 %! "position", [0, 0, 1, 0.5]);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
171 %! b2 = uicontrol (bg, "style", "togglebutton", "units", "normalized", ...
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
172 %! "position", [0, 0.5, 1, 0.5]);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
173 %! assert (get (bg, "selectedobject"), b1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
174 %! assert (get (b1, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
175 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
176 %! ## select togglebutton 2
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
177 %! set (bg, "selectedobject", b2);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
178 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
179 %! assert (get (b1, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
180 %! assert (get (b2, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
181 %! ## set togglebutton 1
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
182 %! set (b1, "value", 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
183 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
184 %! assert (get (bg, "selectedobject"), b1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
185 %! assert (get (b1, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
186 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
187 %! ## unset all togglebuttons
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
188 %! set (bg, "selectedobject", []);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
189 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
190 %! assert (get (b1, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
191 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
192 %! ## change style of selected button
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
193 %! set (b1, "value", 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
194 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
195 %! assert (get (bg, "selectedobject"), b1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
196 %! set (b1, "style", "pushbutton");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
197 %! assert (get (bg, "selectedobject"), []);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
198 %! ## add new button
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
199 %! b3 = uicontrol (bg, "style", "togglebutton");
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
200 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
201 %! assert (get (bg, "selectedobject"), b3);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
202 %! assert (get (b2, "value"), 0);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
203 %! assert (get (b3, "value"), 1);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
204 %! ## remove selected button
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
205 %! delete (b3);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
206 %! pause (0.5);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
207 %! assert (get (bg, "selectedobject"), []);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
208 %! unwind_protect_cleanup
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
209 %! close (hf);
5b9067c17e4b Keep track of children in uibuttongroup (bug #55230).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26877
diff changeset
210 %! end_unwind_protect