Borrar filtros
Borrar filtros

hyperlink and center alignment in msgbox

23 visualizaciones (últimos 30 días)
Yang Yang
Yang Yang el 25 de En. de 2020
Comentada: Adam Danz el 24 de Ag. de 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

Respuesta aceptada

Adam Danz
Adam Danz el 26 de En. de 2020
Editada: Adam Danz el 28 de En. de 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 comentarios
Andre Pereira
Andre Pereira el 24 de Ag. de 2020
how can I had an image to this msgbox?
Adam Danz
Adam Danz el 24 de Ag. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by