Skip to content

Commit 2367036

Browse files
committed
Repeat scalar button height/width for each button
1 parent a1c7661 commit 2367036

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

widgets/+wt/ButtonGrid.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ function onButtonPushed(obj,evt)
180180

181181
end %function
182182

183+
function updateGridForButton(obj, prop, value)
184+
% Update main grid properties to value
185+
186+
% If value is a scalar, repeat it for every button.
187+
if isscalar(value)
188+
nCells = numel(obj.Grid.(prop));
189+
value = repmat(value, 1, nCells);
190+
end
191+
obj.Grid.(prop) = value;
192+
193+
end %function
194+
183195
end %methods
184196

185197

@@ -191,14 +203,14 @@ function onButtonPushed(obj,evt)
191203
value = obj.Grid.ColumnWidth;
192204
end
193205
function set.ButtonWidth(obj,value)
194-
obj.Grid.ColumnWidth = value;
206+
obj.updateGridForButton("ColumnWidth", value);
195207
end
196208

197209
function value = get.ButtonHeight(obj)
198210
value = obj.Grid.RowHeight;
199211
end
200212
function set.ButtonHeight(obj,value)
201-
obj.Grid.RowHeight = value;
213+
obj.updateGridForButton("RowHeight", value);
202214
end
203215

204216
end %methods

0 commit comments

Comments
 (0)