Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
hyperlink on static text in GUI?

Subject: hyperlink on static text in GUI?

From: Vihang Patil

Date: 3 Mar, 2008 09:26:06

Message: 1 of 11

Hello
I would like to know if it is possible to have a HyperLink
on the static text in the gui, which would point to a
website when clicked on?
I tried placing this in the String Property of the Static
Text Box, but it doesnt work

'<a href="http://www.konem.com">Developed By Konem
Solutions</a>'

Vihang

Subject: hyperlink on static text in GUI?

From: Vihang Patil

Date: 3 Mar, 2008 09:34:06

Message: 2 of 11

Referring to the above post I tried using the ButtonDown
callback property of the static text, but it has a lot of
limitations.
Vihang

Subject: hyperlink on static text in GUI?

From: Rajesh Acharya

Date: 22 Apr, 2009 10:07:01

Message: 3 of 11

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message <fqggme$d0e$1@fred.mathworks.com>...
> Referring to the above post I tried using the ButtonDown
> callback property of the static text, but it has a lot of
> limitations.
> Vihang


Hi all,
Looking for the solution of the exact same problem. Anybody for help?

Subject: hyperlink on static text in GUI?

From: Praetorian

Date: 22 Apr, 2009 12:48:16

Message: 4 of 11

On Apr 22, 4:07=A0am, "Rajesh Acharya" <rv_acha...@yahoo.com> wrote:
> "Vihang Patil" <vihang_pa...@yahoo.com> wrote in message <fqggme$d0...@fr=
ed.mathworks.com>...
> > Referring to the above post I tried using the ButtonDown
> > callback property of the static text, but it has a lot of
> > limitations.
> > Vihang
>
> Hi all,
> Looking for the solution of the exact same problem. Anybody for help?

Look at my questions at the bottom of the following post and Yair's
replies ...
http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/

HTH,
Ashish.

Subject: hyperlink on static text in GUI?

From: Rajesh Acharya

Date: 27 Apr, 2009 09:31:01

Message: 5 of 11

Thank you for the reply
although i must say that i could not understand much of the discussion because i have never worked on JAva and i am also relatively new to matlab.
I found some material in file exchange which worked. thanks again

Subject: hyperlink on static text in GUI?

From: Yair Altman

Date: 27 Apr, 2009 10:09:02

Message: 6 of 11

"Rajesh Acharya" <rv_acharya@yahoo.com> wrote in message <gt3u0l$o12$1@fred.mathworks.com>...
> Thank you for the reply
> although i must say that i could not understand much of the discussion because i have never worked on JAva and i am also relatively new to matlab.
> I found some material in file exchange which worked. thanks again

You don't need to understand Java. A working example is in my FindJObj utility, which displays a static hyperlink at the bottom of the figure window in interactive (no outputs) mode.

For anyone who doesn't want to search the code, here's a snippet that you can copy-paste:

labelStr = '<html><center><a href="">Undocumented<br>Matlab.com';
cbStr = 'web(''http://Undocumentedmatlab.com'');';
hButton = uicontrol('string',labelStr,'pos',[20,20,100,35],'callback',cbStr);
jButton = findjobj(hButton); % get FindJObj from the File Exchange
jButton.setCursor(java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton.setContentAreaFilled(0); % or: jButton.setBorder([]);

Yair Altman
http://UndocumentedMatlab.com
 
(also look at a recent post I made about undocumented button customizations: http://undocumentedmatlab.com/blog/button-customization/ )

Subject: hyperlink on static text in GUI?

From: venky.iitd@gmail.com

Date: 27 Apr, 2009 12:39:17

Message: 7 of 11

Hi Yair

I tried using your your above code to send an E-mail. It works fine
for a PushButton.
But if I keep 'style', 'text' then it doesn't works. Can you tell me
how to do it for static text ?
This is the code I am using

Email = 'venky@gmail.com';
labelStr = 'send E-Mail';
cbStr = 'web([''mailto:'',Email]);';
hButton = uicontrol('style', 'text', 'string',labelStr,'pos',
[20,20,220,20],'callback',cbStr);
jButton = findjobj(hButton); % get FindJObj from the File Exchange
jButton.setCursor(java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

Subject: hyperlink on static text in GUI?

From: venky.iitd@gmail.com

Date: 27 Apr, 2009 12:57:41

Message: 8 of 11

sorry.. I understand that 'text' doesn't have any callback function.

is there any other way?

Subject: hyperlink on static text in GUI?

From: venky.iitd@gmail.com

Date: 27 Apr, 2009 13:14:04

Message: 9 of 11

It is working fine using

'ButtonDownFcn', cbStr, 'Enable', 'inactive'

Subject: hyperlink on static text in GUI?

From: Yair Altman

Date: 27 Apr, 2009 21:32:01

Message: 10 of 11

> I tried using your your above code to send an E-mail. It works fine for a PushButton.
> But if I keep 'style', 'text' then it doesn't works. Can you tell me how to do it for static text ?

Unfortunately, text label uicontrols do NOT support HTML labels as buttons and other uicontrol styles do. This is why I often use a button with no border, just as the code I posted above. If looks exactly like a text label (not a button), accepts HTML (which 'text' styles don't), and enables simple callbacks without having to make the control inactive. For simple hyperlinks this is probably your best option (yes there are other options).

Yair Altman
http://UndocumentedMatlab.com
 

Subject: hyperlink on static text in GUI?

From: Arnaud Delorme

Date: 16 Jul, 2011 16:50:09

Message: 11 of 11

I have written a small function that allows to make vertical text in Matlab GUIs.

fig = figure;
tmp = uicontrol('style', 'text', 'string', 'Vertical text', 'tag', 'test');
putverticaltext(fig, 'test', 'Vertical text');
----
function putverticaltext(fig, tag, str);

    tmpobj = findobj(fig, 'tag', tag)
    tmppos = get(tmpobj, 'position')
    delete(tmpobj);
    axes('position', tmppos);
    axis('off');
    
    if ~iscell(str), str = { str }; end;
    maxX = 0;
    for index = 1:length(str)
        tmp = text(index, 0, str{index});
        maxX = index+1;
        set(tmp, 'rotation', 90, 'fontweight', 'bold');
    end;
    xlim([0 maxX]);


"Yair Altman" wrote in message <gt588h$5pe$1@fred.mathworks.com>...
> > I tried using your your above code to send an E-mail. It works fine for a PushButton.
> > But if I keep 'style', 'text' then it doesn't works. Can you tell me how to do it for static text ?
>
> Unfortunately, text label uicontrols do NOT support HTML labels as buttons and other uicontrol styles do. This is why I often use a button with no border, just as the code I posted above. If looks exactly like a text label (not a button), accepts HTML (which 'text' styles don't), and enables simple callbacks without having to make the control inactive. For simple hyperlinks this is probably your best option (yes there are other options).
>
> Yair Altman
> http://UndocumentedMatlab.com
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us