Comments on: HTML support in Matlab uicomponents https://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents Charting Matlab's unsupported hidden underbelly Fri, 21 Apr 2023 18:07:53 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Martin Lechnerhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-507214 Wed, 06 Nov 2019 04:26:35 +0000 https://undocumentedmatlab.com/?p=14#comment-507214 For html strings you have to replace the special characters with the entity names (e.g. replace

'<' by '&lt;' or 
'>' by '&gt;'

).
For a description to entity names and a list of the important ones see https://www.w3schools.com/html/html_entities.asp
A full list character entity names can be seen in https://dev.w3.org/html5/html-author/charref.

]]>
By: K Xuhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-506283 Thu, 31 Oct 2019 16:03:55 +0000 https://undocumentedmatlab.com/?p=14#comment-506283 Trouble is, when there are “<" in the string, they are not shown in Matlab! Any ideas to fix it?

]]>
By: Chaithya G Rhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-413744 Mon, 18 Sep 2017 09:43:46 +0000 https://undocumentedmatlab.com/?p=14#comment-413744 Hey Yair,
Thanks for such an awesome blog… I never knew such great capabilities existed, most of which i really needed…
Thanks again..

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-403736 Sun, 26 Mar 2017 18:38:37 +0000 https://undocumentedmatlab.com/?p=14#comment-403736 @darsh – yes it is possible using <div> or <tr>/<td>, but this has some drawbacks:

hButton.String = '<html><tr><td width=9999 align=left>Left-aligned'

Instead, I suggest using the text alignment methods/properties of the underlying Java control: https://undocumentedmatlab.com/blog/button-customization

]]>
By: darshhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-403579 Fri, 24 Mar 2017 01:19:08 +0000 https://undocumentedmatlab.com/?p=14#comment-403579 while using html in Matlab uitable cell to change color , can I at the same time also specify alignment to centre or left? I don’t know html and am trying to work out if this is possible or not
data(1,1)='<html><font bgcolor=#FF8800>1</font></html>’

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-386971 Tue, 30 Aug 2016 13:37:58 +0000 https://undocumentedmatlab.com/?p=14#comment-386971 @Meade – it’s not Matlab that ignores the align directive but rather the underlying Java Swing behavior, which snugly fits the text in the center of the button, and of course aligning text within a tight-fitting box has no effect. The workaround I suggested simply forces Swing to use a non-tightly-fitting boundary box, within which you can indeed align the text. It’s a pretty standard HTML/CSS behavior workaround, and any decent web developer could probably find several similar alternatives.

]]>
By: Meadehttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-386958 Tue, 30 Aug 2016 11:20:28 +0000 https://undocumentedmatlab.com/?p=14#comment-386958 @Yair

This is a great work-around!
I’m guessing by your suggestion that Matlab doesn’t interpret any of the ‘align’ commands for text in naked Matlab uibuttons?
As for suggestion two, I’m very familiar with your great |findjobj| utility. I use it all the time. I was hoping to avoid jButtons if possible, but they might be best choice afterall.
Many thanks!
meade

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-386403 Tue, 23 Aug 2016 17:05:46 +0000 https://undocumentedmatlab.com/?p=14#comment-386403 @Meade – You can use an HTML string such as this:

pxPos = getpixelposition(hButton);
hButton.String = ['<html><div width="' num2str(pxPos(3)-20) 'px" align="right">text'];  % button margins use 20px

A better solution is to use the findjobj utility as explained here. This would be independent of the button’s pixel-size and would work even when the button is resized.

]]>
By: Meadehttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-386047 Fri, 19 Aug 2016 15:57:27 +0000 https://undocumentedmatlab.com/?p=14#comment-386047 Is it possible to change the horizontal & vertical alignment of the pushbutton string with CSS tags?
I see that most directives work, but I don’t see any effect from:

hButton.String = '<html><div style="text-align:right">My RIGHT ALIGNED string';

Much thanks for all you do!

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-382119 Sat, 02 Jul 2016 19:17:02 +0000 https://undocumentedmatlab.com/?p=14#comment-382119 @Momo – you cannot include external CSS files. You need to specify the CSS directives directly in the HTML string as I have shown above.

]]>
By: Momohttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-381989 Fri, 01 Jul 2016 16:26:20 +0000 https://undocumentedmatlab.com/?p=14#comment-381989 Please refer to this : http://www.bestcssbuttongenerator.com/

]]>
By: Momohttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-381987 Fri, 01 Jul 2016 16:23:23 +0000 https://undocumentedmatlab.com/?p=14#comment-381987 @Yair Thank you for your reply.

I have been trying to include a css file for a while but I always get the html code as a string on the button. Can you help me with this issue ? Please refer to the example below (HTML code and it’s corresponding CSS code).

HTML CODE: <a href="#" rel="nofollow">green</a>
 
CSS CODE: .myButton {
	background-color:#44c767;
	-moz-border-radius:28px;
	-webkit-border-radius:28px;
	border-radius:28px;
	border:1px solid #18ab29;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:Arial;
	font-size:17px;
	padding:16px 31px;
	text-decoration:none;
	text-shadow:0px 1px 0px #2f6627;
}
.myButton:hover {
	background-color:#5cbf2a;
}
.myButton:active {
	position:relative;
	top:1px;
}
]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-381976 Fri, 01 Jul 2016 15:04:32 +0000 https://undocumentedmatlab.com/?p=14#comment-381976 @Momo – yes, you can include CSS in your controls, even those created using GUIDE. Simply update the control’s String property to include the relevant HTML info. For example:

hButton.String = '<html><div style="color:red; text-decoration:line-through;">Click me!';

Note that not all CSS directives are supported by Java Swing (which is the underlying mechanism that parses the HTML/CSS directives).

]]>
By: Momohttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-381971 Fri, 01 Jul 2016 14:46:33 +0000 https://undocumentedmatlab.com/?p=14#comment-381971 Is it possible to integrate CSS to Matlab Guide ?

I am trying to create one of the buttons here : https://codepen.io/bartekd/pen/qFsDf in my Matlab Guide figure. Is it feasible ?

Thank you in advance.

]]>
By: Aaronhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-363043 Wed, 02 Dec 2015 15:24:10 +0000 https://undocumentedmatlab.com/?p=14#comment-363043 I was able to fix this by putting an ‘&’ before the string as well as using it as an html character.

]]>
By: Aaronhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-363041 Wed, 02 Dec 2015 15:18:30 +0000 https://undocumentedmatlab.com/?p=14#comment-363041 I am trying to write Latin characters in a uimenu, such as: á or ñ. However, the ‘&’ symbol is reserved for uimenus to allow mnemonic access to items and so doesn’t display the characters correctly. Do you know a way around this? Is Java required for this?

Thanks in advance.

]]>
By: Rendering of colored listbox text using HTML in deployed application - Tech Magazinehttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-360017 Wed, 28 Oct 2015 12:01:06 +0000 https://undocumentedmatlab.com/?p=14#comment-360017 […] found how to do it using HTML code, as an undocumented feature, here. Basically the code, copied/pasted from Yair’s website, looks as […]

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-340797 Wed, 10 Dec 2014 13:38:29 +0000 https://undocumentedmatlab.com/?p=14#comment-340797 Next time, use my uiinspect and/or checkClass utilities.

]]>
By: Alex Fhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-340794 Wed, 10 Dec 2014 13:36:24 +0000 https://undocumentedmatlab.com/?p=14#comment-340794 Sorry. It should have read ….. demon speed* reply….

]]>
By: Alex Fhttps://undocumentedmatlab.com/blog_old/html-support-in-matlab-uicomponents#comment-340793 Wed, 10 Dec 2014 13:35:10 +0000 https://undocumentedmatlab.com/?p=14#comment-340793 Yair, thank you for your demon reply. At times it gives the impression you are an 24hr AI software working. :) I used methods(jLabel) yesterday but didn’t show setFont, neither I could tab-complete it. Not sure why. Next time I will assume is there whether I see it or not. Thanks a million.

]]>