Custom warning icon?

168 views
Skip to first unread message

Sketch

unread,
Mar 30, 2022, 9:57:41 AM3/30/22
to Blockly
Hi all!

I was wondering if there is a way to create a custom warning icon.
I'm looking for a more modern warning icon since the one that blockly uses doesn't really fit my block color\design language.

Thanks

Neil Fraser

unread,
Mar 30, 2022, 10:05:50 AM3/30/22
to blo...@googlegroups.com
Yes, you'll need to edit or override Warning.prototype.drawIcon_ :
It is just SVG.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/7d8c9f0d-da91-4c90-826a-315d771442e0n%40googlegroups.com.


--

Beka Westberg

unread,
Mar 30, 2022, 10:29:31 AM3/30/22
to blo...@googlegroups.com
Hello,

Just wanted to note that modifying warning.js is possible if you're forking Blockly, but the core team strongly recommends against forking. Forking makes it harder for you to keep up with releases, get the latest features of Blockly, or use plugins. Instead the core team recommends requiring Blockly via NPM.

Also note that while drawIcon_ is technically protected, I wouldn't recommend overriding it. The icons were never designed to be modified/subclassed/etc. So while overriding drawIcon_ works right now, if the core team ever decides to refactor icons to make them more extensible, it may not work in the future.

So all that is to say that the core team doesn't have a great way of doing what you want to do right now. And given that, there may be future maintenance costs if you decide to override things in icons.

Sorry that's not a great answer :/ But I just wanted to give you a heads up.

Best wishes,
--Beka

Sketch

unread,
Mar 31, 2022, 1:56:10 PM3/31/22
to Blockly
Thanks Beka and Neil.

I'll think i'll override the drawIcon_ function.
And if the team ever changes it i'll check that out.

Thanks

Op woensdag 30 maart 2022 om 16:29:31 UTC+2 schreef bwes...@google.com:
Reply all
Reply to author
Forward
0 new messages