The page background is blue (set with a webstyle). The client would like something different. I could just change the webstyle, but the next client (I am, perhaps, being a bit optimistic here) will likely want yet a third color. So, I would like to change the background color on the fly. This would seem to be fairly easy to do with javascript, but it’s not clear to me how to get at the page.
The page background is blue (set with a webstyle). The client would like something different. I could just change the webstyle, but the next client (I am, perhaps, being a bit optimistic here) will likely want yet a third color. So, I would like to change the background color on the fly. This would seem to be fairly easy to do with javascript, but it’s not clear to me how to get at the page.[/quote]
Here is some JavaScript slightly modified from the code in the Webpage shown event of the demo of RubberViewsWE. You can put any RGB value in there.
You’re right. I have a set number of colors/webstyles for the user to choose from. I could have sworn I had a color picker in there but I didn’t. Just a pop-up with a fixed set of colors…
well, you could do a popup with 16.7 million colors in it… sorry, I’m a bit punchy this morning.
There are two ‘features’ of Xojo styles that I’m not fond of:
a) they have to be created in the IDE and are immutable
b) only one style can be assigned to a control at a time
You can create subclasses of styles which is a bit of a workaround for (b) but we do miss out on some of the great flexibilities of CSS in native Xojo stuff. Yes, we can punch through Xojo and address styles directly via Javascript but it would be nice to see this feature set mature over time. I’m not sure what form it should take though…
what you really want is the ability to alter style data in a xojo condoned way you can alter anything anyway via execute javascript, but that steps outside of the official supported behavior and who knows if it will still work that same way with the next release and if you have trouble with something after changing it youre certainly not going to get support on that. So perhaps join in this feedback request:
[quote=215104:@Steve Upton]well, you could do a popup with 16.7 million colors in it… sorry, I’m a bit punchy this morning.
There are two ‘features’ of Xojo styles that I’m not fond of:
a) they have to be created in the IDE and are immutable
b) only one style can be assigned to a control at a time
You can create subclasses of styles which is a bit of a workaround for (b) but we do miss out on some of the great flexibilities of CSS in native Xojo stuff. Yes, we can punch through Xojo and address styles directly via Javascript but it would be nice to see this feature set mature over time. I’m not sure what form it should take though…[/quote]
I don’t remember where I read it, could be from a Greg’s post, that Xojo plans on improving the styles. No more details though.
In the meantime, the JavaScript method is not so bad, really. It can be put in a method and become as simple as setting the properties in Desktop.
One can also use a css style starting with a dot (ie .myStyle) in the HTMLHeader, and when an empty WebStyle of the same name without the dot (myStyle) is applied to a control, it picks the CSS.
Looking forward to see what Xojo will come up with, but it may be a while…