hyperlink and center alignment in msgbox

39 Ansichten (letzte 30 Tage)
Yang Yang
Yang Yang am 25 Jan. 2020
Kommentiert: Adam Danz am 24 Aug. 2020
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

Akzeptierte Antwort

Adam Danz
Adam Danz am 26 Jan. 2020
Bearbeitet: Adam Danz am 28 Jan. 2020
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 Kommentare
Andre Pereira
Andre Pereira am 24 Aug. 2020
how can I had an image to this msgbox?
Adam Danz
Adam Danz am 24 Aug. 2020
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by