<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WebStyles &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/webstyles/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Mon, 07 Jul 2025 17:26:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Web Framework Updates in 2025r2</title>
		<link>https://blog.xojo.com/2025/07/08/web-framework-updates-in-2025r2/</link>
		
		<dc:creator><![CDATA[Ricardo Cruz]]></dc:creator>
		<pubDate>Tue, 08 Jul 2025 18:01:00 +0000</pubDate>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[2025r2]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[WebMapViewer]]></category>
		<category><![CDATA[WebStyles]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=14977</guid>

					<description><![CDATA[Featuring WebStyle state support for creating more polished user interfaces, enhanced event handling capabilities, and a collection of bug fixes and utility improvements, 2025r2 continues&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Featuring WebStyle state support for creating more polished user interfaces, enhanced event handling capabilities, and a collection of bug fixes and utility improvements, 2025r2 continues improvements to your Web Application development experience with Xojo.</p>



<h2 class="wp-block-heading"><strong>Added Support for WebStyle States</strong></h2>



<p>Working on Desktop projects is all fun and jokes. You can just change how the whole application looks every time your application users move their mouse one pixel to the left. Latency? Who cares!</p>



<p>In order to achieve the same results, WebStyle has been improved to support states. Hover, Pressed and Visited.</p>



<ul class="wp-block-list">
<li><strong>WebStyle.Hover</strong><br>This is the style that will be applied when the mouse is over the element</li>



<li><strong>WebStyle.Pressed</strong><br>This is the style that will be applied when the user is pressing a mouse button in the element</li>



<li><strong>WebStyle.Visited</strong><br>This style can be used with WebLink instances. Used to let the user know the browser has visited that link in the past</li>
</ul>



<p>Consider the following WebContainer:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="686" src="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.31.08-1024x686.png" alt="" class="wp-image-14978" srcset="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.31.08-1024x686.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.31.08-300x201.png 300w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.31.08-768x514.png 768w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.31.08-1536x1029.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.31.08-2048x1371.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>In this case, it&#8217;s just a container with a WebLabel inside.</p>



<p>The Opening event contains the following code:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="686" src="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.34.34-1024x686.png" alt="" class="wp-image-14979" srcset="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.34.34-1024x686.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.34.34-300x201.png 300w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.34.34-768x514.png 768w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.34.34-1536x1029.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.34.34-2048x1371.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Please note I&#8217;m using named colors. You can read more about named colors in <a href="https://blog.xojo.com/2024/10/01/introducing-named-color-and-css-classes-in-xojo-web/" data-type="link" data-id="https://blog.xojo.com/2024/10/01/introducing-named-color-and-css-classes-in-xojo-web/">Introducing Named Color and CSS Classes in Xojo Web</a>. If you try using another Bootstrap theme, the same code will use the new color palette without modifications.</p>



<p>Here is the result:</p>



<figure class="wp-block-video aligncenter"><video height="1044" style="aspect-ratio: 1392 / 1044;" width="1392" controls src="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-10.32.14.mp4.mp4"></video></figure>



<p>Combined with <code>WebStyle.AddTransition</code>, it opens the gates for more interesting GUIs. Let&#8217;s add some transitions to our code:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="686" src="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.41.12-1024x686.png" alt="" class="wp-image-14981" srcset="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.41.12-1024x686.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.41.12-300x201.png 300w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.41.12-768x514.png 768w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.41.12-1536x1029.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.41.12-2048x1371.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Let&#8217;s try the project again:</p>



<figure class="wp-block-video"><video height="1044" style="aspect-ratio: 1392 / 1044;" width="1392" controls src="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-10.41.58.mp4.mp4"></video></figure>



<p>Neat! Let&#8217;s go crazy for a second with more complex effects:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="686" src="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.57.15-1024x686.png" alt="" class="wp-image-14983" srcset="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.57.15-1024x686.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.57.15-300x201.png 300w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.57.15-768x514.png 768w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.57.15-1536x1029.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-10.57.15-2048x1371.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The result:</p>



<figure class="wp-block-video"><video height="1044" style="aspect-ratio: 1392 / 1044;" width="1392" controls src="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-10.57.58.mp4.mp4"></video></figure>



<p>You should definitely avoid going that crazy, this is just to show the possibilities. As Dr. Ian Malcolm said &#8230; <em>&#8220;Your scientists were so preoccupied with whether or not they could, they didn&#8217;t stop to think if they should.&#8221;</em></p>



<h2 class="wp-block-heading"><strong>WebContainer.Pressed</strong></h2>



<p>Speaking about pressing on things, WebContainer.Pressed event is now available, so you don&#8217;t need to place a WebLabel or a WebContainer on top just to capture that event anymore. The event comes with some coordinates, just in case you need them.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="686" src="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-11.05.54-1024x686.png" alt="" class="wp-image-14985" srcset="https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-11.05.54-1024x686.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-11.05.54-300x201.png 300w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-11.05.54-768x514.png 768w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-11.05.54-1536x1029.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/06/Captura-de-pantalla-2025-06-17-a-las-11.05.54-2048x1371.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The result:</p>



<figure class="wp-block-video"><video height="1044" style="aspect-ratio: 1392 / 1044;" width="1392" controls src="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-11.05.36.mp4.mp4"></video></figure>



<h2 class="wp-block-heading"><strong>Other changes</strong></h2>



<p><strong>WebToolbar.Resized</strong></p>



<p>Trying to tweak your design for different screen sizes? If WebToolbar&#8217;s automated behavior is not enough, you can implement the new WebToolbar.Resized event and adapt the contents. This is useful when you are reusing the same WebToolbar subclass in multiple WebPages. You will be able to place this code in just one place.</p>



<p><strong>Exporting maps with WebMapViewer</strong></p>



<p>Same as with MobileMapViewer. You can now use WebMapViewer.ToPicture method to export the current map. Like WebChart.ToPicture, due to the asynchronous nature of Web projects, the picture will be available in the new WebMapViewer.RequestedPicture event.</p>



<p><strong>Updated DataTables</strong></p>



<p>Last, but not least, DataTables has been upgraded from v1.13.4 to v2.2.2.</p>



<h2 class="wp-block-heading"><strong>That&#8217;s (not) all!</strong></h2>



<p>As always, please make sure to check the <a href="https://documentation.xojo.com/versions/2025r2/resources/release_notes/2025r2.html">release notes</a> for a detailed list of new features and bug fixes. The Web framework is built on top of Xojo, new global features or bug fixes also applies to Web, including improvements to Console projects. Xojo Web is &#8220;just&#8221; a big Console project.</p>



<p>Thank you everyone for reporting, testing beta builds and giving us feedback.</p>



<p>Happy coding!</p>



<p><em>Ricardo has always been curious about how things work. Growing up surrounded by computers</em> he became interested in <em>web technologies in the dial-up connections era. Xojo has been his secret weapon and language of preference since 2018. When he’s not online, chances are he will be scuba diving … or crocheting amigurumis. Find Ricardo on Twitter <a href="https://web.archive.org/web/20220805000833/https://www.twitter.com/piradoiv" target="_blank" rel="noreferrer noopener">@piradoiv</a>.</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		<enclosure url="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-10.32.14.mp4.mp4" length="143729" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-10.41.58.mp4.mp4" length="212247" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-10.57.58.mp4.mp4" length="814128" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2025/06/Grabacion-de-pantalla-2025-06-17-a-las-11.05.36.mp4.mp4" length="321178" type="video/mp4" />

			</item>
		<item>
		<title>Tip: Setting the Background Color in WebDialogs</title>
		<link>https://blog.xojo.com/2021/06/08/tip-setting-the-background-color-in-webdialogs/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Tue, 08 Jun 2021 08:00:00 +0000</pubDate>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Color]]></category>
		<category><![CDATA[WebStyles]]></category>
		<category><![CDATA[Xojo API 2.0]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=8606</guid>

					<description><![CDATA[I was recently asked how to set the background color in a WebDialog. There are a few approaches you can take to accomplish this. The simplest one is to add a rectangle as a layer of the WebDialog and set a color to it. In this tutorial you'll learn how to set the background cool by accessing the style property of the object in the DOM model and setting it there. ]]></description>
										<content:encoded><![CDATA[<p>I was recently asked how to set the background color in a <a href="https://documentation.xojo.com/api/user_interface/web/webdialog.html"><code>WebDialog</code></a>. There are a few approaches you can take to accomplish this. The simplest one is to add a rectangle as a layer of the <strong>WebDialog</strong> and set a color to it. In this tutorial you&#8217;ll learn how to set the background color by accessing the style property of the object in the <strong>DOM</strong> model and setting it there. <span id="more-8606"></span></p>
<p>First, add a new <code>Module</code> to a web project. For this tutorial we&#8217;ll name it <code>WebTools</code>. Next, add the following method to it with a <code>Global</code> scope:</p>
<ul>
<li><strong>Method Name:</strong> <code>ModalBackgroundColor</code></li>
<li><code></code><strong>Parameters:</strong> <code>Extends v As WebDialog, assigns c As String</code></li>
<li><code></code><strong>Scope:</strong> <code>Global</code></li>
</ul>
<p>And type the following snippet of code in the associated Code Editor:</p>
<pre>v.ExecuteJavascript("document.getElementById('" + v.ControlID + "_body').style.backgroundColor='"+c+"';")</pre>
<p>With that done, we only need to call it from the <code>Opening</code> Event Handler of a <code>WebDialog</code> instance to set the desired background color:</p>
<pre>Me.ModalBackgroundColor = "#f00" // Sets the background color to Red.</pre>
<p>This leads to some interesting side effects. For example, the header on the <a href="https://documentation.xojo.com/api/user_interface/web/weblistbox.html"><code>WebListbox</code></a> control and the loupe icon on the <a href="https://documentation.xojo.com/api/user_interface/web/websearchfield.html"><code>WebSearchField</code></a> are transparent. That means that they look good when the background color on the <code>WebDialog</code> is the default white color, but not so good when we set a different background color on the <code>WebDialog</code> instance.</p>
<p>Avoid this issue by accessing the <strong>Style</strong> property on the proper <code>div</code> class on these objects. The tricky part here is to access the instance number whose inner header class we need to change. For that, the approach taken here may be a bit of overkill, but it works.</p>
<p>Such an approach is based on subclassing those <code>WebControls</code> we need to reference. In this case we are going to create subclasses for the <code>WebListBox</code> and the <code>WebSearchField</code>.</p>
<p>Add a new class to the project and name it <code>MyWebListBox</code>, setting its <strong>Super</strong> to <code>WebListBox</code>. Next, add a new shared property with the following values:</p>
<ul>
<li><strong>Shared Property Name:</strong> <code>globalInstance</code></li>
<li><code></code><strong>Data Type:</strong> <code>Dictionary</code></li>
<li><code></code><strong>Scope:</strong> <code>Private</code></li>
</ul>
<p>And a second regular property with these values:</p>
<ul>
<li><strong>Property Name:</strong> <code>instanceNumber</code></li>
<li><code></code><strong>Data Type:</strong> <code>Integer</code></li>
<li><code></code><strong>Scope:</strong> <code>Public</code></li>
</ul>
<p>Next, add the <code>Constructor</code> method to the new class. The IDE will automatically include the code calling its <code>Super</code> class. Then, add a couple lines of code to set the <code>instanceNumber</code> property to the last index of the <code>globalInstance</code> shared property array. The final code for the method will look like this:</p>
<pre>Super.Constructor
If globalInstance = Nil Then globalInstance = New Dictionary
Var instances() As MyWebListBox
If Session &lt;&gt; Nil Then
  If globalInstance.HasKey(Session) Then
    instances = globalInstance.Value(Session)
  End If
  instances.add Me
  instanceNumber = instances.lastindex
  globalInstance.Value(Session) = instances
End If</pre>
<p>Add next the <code>Closed</code> Event handler to the subclass, typing the following snippet of code in the associated Code Editor:</p>
<pre>If Session &lt;&gt; Nil Then
  If globalInstance.HasKey(Session) Then
    Var instances() As MyWebListBox = globalInstance.Value(Session)
    instances.Remove(Me.instanceNumber)
    For n As Integer = Me.instanceNumber To instances.LastIndex
      instances(n).instanceNumber = instances(n).instanceNumber-1
    Next
    globalInstance.Value(Session) = instances
  End If
End If</pre>
<p>Because we are using the <code>Closed</code> event handler in the subclass, we need to add it again using the Event Definition option (keeping the same name, number of parameters and returned type). This way the instances based on this subclass will be able to add that event too.</p>
<p>Repeat the same steps to add a new <code>MyWebSearchField</code> class whose Super is set to <code>WebSearchField</code>.</p>
<p><img loading="lazy" decoding="async" class="wp-image-8632 size-full aligncenter" src="https://blog.xojo.com/wp-content/uploads/2021/06/BacgroundWebClasses.png" alt="" width="290" height="422" srcset="https://blog.xojo.com/wp-content/uploads/2021/06/BacgroundWebClasses.png 290w, https://blog.xojo.com/wp-content/uploads/2021/06/BacgroundWebClasses-206x300.png 206w" sizes="auto, (max-width: 290px) 100vw, 290px" /></p>
<p> </p>
<p>The code associated with the <code>Constructor</code> method for the <code>MyWebSearchField</code> is as follows:</p>
<pre>Super.Constructor
If globalInstance = Nil Then globalInstance = New Dictionary
If Session &lt;&gt; Nil Then
  Var instances() As MyWebSearchField
  If globalInstance.HasKey(Session) Then
    instances = globalInstance.Value(Session)
  End If
  instances.add Me
  instanceNumber = instances.lastindex  
  globalInstance.Value(Session) = instances
End If
</pre>
<p>And the code associated with the <code>Closed</code> Event Handler should be this one:</p>
<pre>If Session &lt;&gt; Nil Then
  If globalInstance.HasKey(Session) Then
    Var instances() As MyWebSearchField = globalInstance.Value(Session)
    instances.Remove(Me.instanceNumber)
    For n As Integer = Me.instanceNumber To instances.LastIndex
      instances(n).instanceNumber = instances(n).instanceNumber-1
    Next
    globalInstance.Value(Session) = instances
  End If
End If</pre>
<p>With both both classes created, add them to a WebDialog instance (the one we named <code>WebDialog1</code>). Then, include the following line of code in the <code>Shown</code> event handler for each of these instances:</p>
<p><img loading="lazy" decoding="async" class="size-large wp-image-8608 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2021/06/SettingClasses-1024x495.png" alt="" width="1024" height="495" srcset="https://blog.xojo.com/wp-content/uploads/2021/06/SettingClasses-1024x495.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/06/SettingClasses-300x145.png 300w, https://blog.xojo.com/wp-content/uploads/2021/06/SettingClasses-768x371.png 768w, https://blog.xojo.com/wp-content/uploads/2021/06/SettingClasses.png 1059w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>In the case of the <code>ListBox1</code> instance:</p>
<pre>Me.ExecuteJavascript("document.getElementsByClassName(""dataTables_scrollHeadInner"")["+me.instanceNumber.tostring+"].style.backgroundColor='#f00';") // This will set the listbox header background color to Red</pre>
<p>Of course, you can improve this by accepting a variable color reference string instead of using the constant red value here (&#8220;#f00&#8221;).</p>
<p>And for the <code>SearchField1</code> instance:</p>
<pre>Me.ExecuteJavascript("document.getElementsByClassName(""input-group-append"")["+me.instanceNumber.toString+"].style.backgroundColor='#fff';") // This will set the "loupe" icon background color to White</pre>
<p>Now, we need to make sure that both the <code>WebListbox</code> and the <code>WebSearchField</code> instances are reset when we are done, something we can do by calling their <code>Close</code> method from the <code>Dismissed</code> event handler added to the <code>WebDialog1</code> instance in the project:</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-8615 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2021/06/Dismissed.png" alt="" width="496" height="158" srcset="https://blog.xojo.com/wp-content/uploads/2021/06/Dismissed.png 496w, https://blog.xojo.com/wp-content/uploads/2021/06/Dismissed-300x96.png 300w" sizes="auto, (max-width: 496px) 100vw, 496px" /></p>
<p>Run the example project and you&#8217;ll see how the first ListBox instance (on the <code>WebPage1</code> page) keeps the header color as transparent (white, because the page background color is white), while the second one displayed by the WebDialog is set to red. Also, the SearchField control displays the loupe icon with a white background color.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-8609 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2021/06/WebDialogBGColor.png" alt="" width="934" height="473" srcset="https://blog.xojo.com/wp-content/uploads/2021/06/WebDialogBGColor.png 934w, https://blog.xojo.com/wp-content/uploads/2021/06/WebDialogBGColor-300x152.png 300w, https://blog.xojo.com/wp-content/uploads/2021/06/WebDialogBGColor-768x389.png 768w" sizes="auto, (max-width: 934px) 100vw, 934px" /></p>
<h2>Bonus Tip</h2>
<p>Once you know the mechanics of how to access the proper ID and set the background on the WebDialog, it is easy to set an image as the background instead of a color. For example, this line of code in the <code>Shown</code> event of the <code>WebDialog1</code> instance will load the Xojo logo as the background image:</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-8610 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2021/06/BackgroundImage.png" alt="" width="902" height="466" srcset="https://blog.xojo.com/wp-content/uploads/2021/06/BackgroundImage.png 902w, https://blog.xojo.com/wp-content/uploads/2021/06/BackgroundImage-300x155.png 300w, https://blog.xojo.com/wp-content/uploads/2021/06/BackgroundImage-768x397.png 768w" sizes="auto, (max-width: 902px) 100vw, 902px" /></p>
<pre>Me.ModalBackgroundImage = "https://www.xojo.com/assets/img/logo.png"</pre>
<p><code>ModalBackgroundImage</code> is another method added to the <code>WebTools</code> module using the following signature:</p>
<ul>
<li><strong>Method Name:</strong> <code>ModalBackgroundImage</code></li>
<li><code></code><strong>Parameters:</strong> <code>Extends v as WebDialog, Assigns url As String</code></li>
</ul>
<p>Add the following associated code:</p>
<pre>Var s As String = "document.getElementById('" + _
v.ControlID + "_body').style.backgroundImage=""url('"+url+"')"";"

v.ExecuteJavascript(s)</pre>
<p>Now that you have the basics down, you can go even further and set other background attributes such as not repeating the image, setting the image size and more.</p>


<p>Questions? Ask me on Twitter&nbsp;<a href="https://twitter.com/xojoes">@XojoES</a>&nbsp;or on the&nbsp;<a href="https://forum.xojo.com/u/javier_menendez/summary">Xojo Forum</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WebStyles and Web Framework 2.0</title>
		<link>https://blog.xojo.com/2020/08/28/webstyles-and-web-framework-2-0/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Fri, 28 Aug 2020 19:33:25 +0000</pubDate>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[WebStyles]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=7403</guid>

					<description><![CDATA[One of the big changes in Web Framework 2.0 is that web styles are no longer the primary means of styling controls. Instead themes are used to provide a single, consistent look and feel across the entire application. We made this change because dealing with individual styles became more complex and unwieldy as projects grew bigger. Themes simplify this dramatically. ]]></description>
										<content:encoded><![CDATA[
<p>One of the big changes in Web Framework 2.0 is that web styles are no longer the primary means of styling controls. Instead, themes are used to provide a single, consistent look and feel across the entire application. We made this change because dealing with individual styles became more complex and unwieldy as projects grew bigger. Themes simplify this dramatically. </p>



<h2 class="wp-block-heading">Themes</h2>



<p>Xojo now uses Bootstrap themes, one of which is built-in and used by default. These themes control the entire appearance of all controls from sizes, to colors, to whether or not corners are rounded and more. There are a lot of publicly available Bootstrap themes so if you don&#8217;t care for the built-in one, you can find one on the Internet you like and simply drop it into your project to have it automatically replace the default theme. You can find high-quality, free and Xojo-compatible themes at <a href="https://bootswatch.com">bootswatch.com</a>. Click the Preview button for any theme on that site to see what parts of the appearance of controls will change.</p>



<p>To use one of the the themes at <a href="https://bootswatch.com">Bootswatch.com</a>, click the Download button&#8217;s menu (not the button itself) and choose the file titled <em>bootstrap.min.css</em>. That&#8217;s the only file you need and it must have that file name to work in Xojo. Once you have downloaded your theme, drop it into your project to use it.</p>



<p>Here&#8217;s just a tiny sample of the preview of the Superhero theme:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://blog.xojo.com/wp-content/uploads/2020/08/Bootstrap-Theme-Preview-1024x768.png" alt="" class="wp-image-7405" srcset="https://blog.xojo.com/wp-content/uploads/2020/08/Bootstrap-Theme-Preview-1024x768.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/08/Bootstrap-Theme-Preview-300x225.png 300w, https://blog.xojo.com/wp-content/uploads/2020/08/Bootstrap-Theme-Preview-768x576.png 768w, https://blog.xojo.com/wp-content/uploads/2020/08/Bootstrap-Theme-Preview-1536x1152.png 1536w, https://blog.xojo.com/wp-content/uploads/2020/08/Bootstrap-Theme-Preview-2048x1536.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Customizing Individual Controls</h2>



<p>This doesn&#8217;t mean you can&#8217;t customize individual controls. You still can. Some have properties available you can set in the Inspector but all have a <a href="https://documentation.xojo.com/api/user_interface/web/webstyle.html">Style</a> property that can be changed via code. You can change background color, border color, border thickness, drawing color, opacity as well as font information such as the font itself, size, bold, italic, and strikethrough. You can even add animation through CSS transitions. If you have experience in CSS, you can set just about any property using the Value method.</p>



<h2 class="wp-block-heading">Transitioning Control Appearance from Web Framework 1.0 to 2.0</h2>



<p>Big transitions are rarely easy. However, the bigger your project is, the more time you&#8217;ve likely spent creating dozens of styles and then applying them to many of your controls. Themes solve this problem. You choose a theme, drop it in and the appearance of controls across your entire project is updated. If you are building an app for an organization that already has specific colors and appearance standards in place, using themes in Xojo makes it easy for them to provide you a theme that you can drop in to make sure the app you create for them matches those standards.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
