2

是否可以将 HTML 内容放在 matlab 中的 errodlg/msgbox 的文本中?我知道“乳胶”解释器选项,可以显示乳胶内容,但我需要在消息中向用户显示超链接。

4

2 回答 2

5

不,这是不可能的,因为文本标签不支持 HTML。

您可以使用创建自己的对话框dialog,然后使用一些未记录的功能在其中放置 Java 标签,或者更简单地,您可以将 URL 显示为文本,并有一个按钮显示“访问 URL”,并带有回调调用web命令的函数。

于 2013-06-10T14:37:22.657 回答
1

Matlab msgbox() 和 uialert() 仍然不支持超链接文本,但您可以在没有乳胶解释器的独立图形中设置它。

这是一个向 uifigure 添加蓝色文本的演示,单击该文本会打开一个网页(通过 ButtonDownFcn 回调函数)。“确定”按钮将关闭图形。

% Create message box figure & axes
uifig = uifigure(); 
uiax = uiaxes(uifig,'Position',[0 0 uifig.Position(3:4)]); 
axis(uiax,'off')
% Add hyperlink text
% You don't need Latex interpreter if you're not underlining the link.
th = text(uiax, .5, .3, '\underline{mathworks.com}',...
    'color',[0 0 .8],'FontSize',20,'Interpreter','latex',...
    'HorizontalAlignment','center'); 
th.ButtonDownFcn = @(~,~)web('mathworks.com'); % this opens the website
% Add OK button that closes figure
uibutton(uifig,'Text','Ok','Position',...
    [50,50,75,30],'ButtonPushedFcn',@(h,~)delete(h.Parent))
于 2020-01-26T01:04:19.960 回答