RealTimeDesigner Support Network
Wiki Forums Libraries Docs Support RealTimeDesigner Home
Welcome! Log In Create A New Profile

Advanced

Force Color Check on Item added

Posted by mycustomhoodies 
Force Color Check on Item added
March 01, 2021 05:46PM
I've decided that I'm going to ask questions in here in hopes that we get this board moving again! Working on a new designer and hoping it maybe gets people going with this again.

Alex, my question is this - within the designer, it shows you the color count. The only way for it to update is if you hit the "refresh" link. Is there a way to make so when an element is added, it just refreshes the color checker on it's own. It seems like it wouldn't be that hard considering when you upload artwork, it will tell you almost instantly the color count. I am not sure if this is already an option, and I am not seeing it, but just thought this would be nice. All the major designers do this already, and thought it would be a nice feature.
Re: Force Color Check on Item added
March 05, 2021 09:08AM
Hi there!

Sorry for the late reply, I'm currently remodeling home and this means that also my usual workstation is a little... messy.
Right now I'm replying from my phone.
I'd need to check some codes. I'll return with a probably positive answer pretty soon, I'm rewiring the computer right in these hours.

Alex
Re: Force Color Check on Item added
March 05, 2021 09:13AM
Alex,
No worries! Take your time with your house! Just wanted to see if it was possible. Thanks!
Re: Force Color Check on Item added
March 05, 2021 09:54AM
Ok, I was faster than expected.

Soooooo....
As you probably saw in the code, the "refresh" button actually calls a function named get_shown_colors(), which is responsible of.... calculating and showing colors.
It will always have a little delay, as to check the actuyal colors the RTD has to "simulate" the full design to then check how many unique colors it contains. This is mostly because of custom images, as with those you NEVER know what to expect.

That said: to have a consistent view of currently used colors, attaching the function to events adding items would not be enough. It should probably be invoked also when an item is removed, or a color is changed... in general, every thime anything changes in the design.

There is a function that's called when every item changes. It enqueues various tasks, for example it's also the one keeping live price updated (if you use it).

So, a JS snippet like this placed in your footer code for designer might do the trick. It essentially append the coult colors to change actions:
<script>
OnloadImageActions = (function() {
var cached_function = OnloadImageActions;
return function() {
	cached_function.apply(this, arguments);
	get_shown_colors();
};
}());
</script>

Know that this is a hack though, so testing is a GOOD idea. It injects an actio that might slowdown things at every image refresh, so better try that in several different scenarios.

Let me know!
Re: Force Color Check on Item added
March 06, 2021 01:29PM
Alex,
This works perfect! I was able to do away with the refresh link then and it does update in real time. It does have just a little lag you can notice when it is rechecking, but not too bad and not sure a user is going to notice it over someone that has spent so much time in RTD. Thank you so much!

Scott
Sorry, only registered users may post in this forum.

Click here to login