From fad5a0d4dc77dc7de8b53c6a7900fa0d4a46aeb5 Mon Sep 17 00:00:00 2001 From: David de la Nuez Date: Tue, 2 Jan 2018 11:57:36 -0500 Subject: [PATCH] Add support for controls whose parent is not the uifigure. This allows, for example, a text area inside a panel, to have the text formatted with bold face font. Previously this caused an error. f = uifigure('Position', [680 558 560 420]); p = uipanel(f,'Position',[20 20 520 380]); txa = uitextarea(p, ... 'Value', 'Lorem ipsum', ... 'Position',[20 20 480 340]); mlapptools.fontWeight(txa, 'bold'); --- mlapptools.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mlapptools.m b/mlapptools.m index 33c7cac..61c3fa2 100644 --- a/mlapptools.m +++ b/mlapptools.m @@ -98,7 +98,11 @@ function fontWeight(uiElement, weight) % A method for obtaining the webwindow handle and the widgetID corresponding % to the provided uifigure control. % Get a handle to the webwindow - win = mlapptools.getWebWindow(uiElement.Parent); + p = uiElement.Parent; + while ~isa(p,'matlab.ui.Figure') + p = p.Parent; + end + win = mlapptools.getWebWindow(p); % Find which element of the DOM we want to edit widgetID = mlapptools.getWidgetID(win, mlapptools.getDataTag(uiElement));