hyperlink and center alignment in msgbox

36 次查看(过去 30 天)
how can I insert hyperlink (urls) and center alignment of text in a msgbox.
Or is there any alternative solutions?
Problem: I'm working on a matlab app designer app. I'm at the final stage where I need to create a 'about' of the created link. In the 'about', I need to provide version info, authors, disclamers, affiliations and etc. To make it look nice, I need to make certain part of the text center aligned, and also insert a link of our affiliation. I'm using msgbox for this task at the moment. However, I coud not find a method to center align my text nor inserting hyperlink. Could someone help me with that?
thank you very much!
Yang

采纳的回答

Adam Danz
Adam Danz 2020-1-26
编辑:Adam Danz 2020-1-28
If you are using App Designer or creating apps with the uifigure function, then use uialert instead of msgbox.
However, neither msgbox nor uialert will support a hyperlink.
The workaround is to build the message box yourself. Here's a demo that adds a blue, underlined text to a uifigure that, when clicked, opens a webpage (via a ButtonDownFcn callback function).
The "OK" button will close the figure.
% Create message box figure & axes
uifig = uifigure();
uiax = uiaxes(uifig,'Position',[0 0 uifig.Position(3:4)]);
uiax.Toolbar.Visible = 'off';
axis(uiax,'off')
% Add hyperlink text
% You don't need Latex interpreter if you're not underlining the link.
th = text(uiax, .5, .3, '$\mathrm{\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))
  10 个评论
Adam Danz
Adam Danz 2020-8-24
There is no msgbox in this answer.
To add an image to a plot, first add an axes, then the image. Here's a demo.
There are additional ways to add an image if you're using AppDesigner (images can even be added to buttons).
If you have any other questions, please create a new question in the forum unless it pertains to this thread.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by