UndocumentedMatlab最近发表的一篇文章提到App Designer图形实际上是使用Dojo Toolkit的网页。这意味着我们理论上可以直接操作 HTML DOM 来实现某些原本不可用的 UI 自定义。
下面是 App Designer 图形定义的示例,显示在.m
App Designer 生成的文件中(在 MATLAB R2016a 上):
classdef domDemo < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure % UI Figure
LabelListBox matlab.ui.control.Label % List Box
ListBox matlab.ui.control.ListBox % Item 1, Item 2, Item 3, It...
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 260 147];
app.UIFigure.Name = 'UI Figure';
setAutoResize(app, app.UIFigure, true)
% Create LabelListBox
app.LabelListBox = uilabel(app.UIFigure);
app.LabelListBox.HorizontalAlignment = 'right';
app.LabelListBox.Position = [50 93 44 15];
app.LabelListBox.Text = 'List Box';
% Create ListBox
app.ListBox = uilistbox(app.UIFigure);
app.ListBox.Position = [109 36 100 74];
end
end
methods (Access = public)
% Construct app
function app = domDemo()
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
...看起来像这样:
根据uilistbox
(将我们重定向到完整属性列表的复选框属性页面)的文档,没有办法操纵例如列表项的文本对齐方式。如果是这样的话,
问题:我们如何操作
ListBox
示例应用程序中的 ,使其内容居中对齐,即使这样的设置对我们不可用?