Changing Command Icons of the Toolbar
-
If you create your toolbar within the tools module/class and then refer to the definition of the command as class variable - e.g.
@@cmdA=UI::Command.new("MyToolA"){Sketchup.active_model.select_tool(MyModule.MyToolA.new())} @@cmdA.small_icon=File.join(File.dirname(__FILE__),"MyImages","myToolA_Green.png")
etc... then as circumstances change the image file that's used...
@@cmdA.small_icon=File.join(File.dirname(__FILE__),"MyImages","myToolA_Red.png")
etc...
You can therefore have your various tool-commands permanently referenced as @@cmdA, @@cmdB etc and swap their icons, tooltips and so on, as circumstances change...
-
Thanks TIG, but I already tried that way and it didn't work after the command was added to the toolbar, u can refer to the Mr.K post above.
-
@anton_s said:
Thanks TIG, but I already tried that way and it didn't work after the command was added to the toolbar, u can refer to the Mr.K post above.
It will change ToolTips etc so perhaps if you hide/show the toolbar ?
-
Ya I tried this several ways, text does change but the icons never do(hide, show, remove toolbar and add it again nothing changes).
It seems SU only loads those images once and they can't be refresh through Ruby. -
Yup. Seems that only the tooltip in the Command objects are actually linked to the toolbar objects it represent. The rest seem to be forgotten.
-
Bum!
The best you could do then for something like a 'Play' > 'Stop' button is to have two buttons side by side, with one disabled [grayed-out] if the other one is enabled - using a validation_proc... -
@tig said:
Bum!
The best you could do then for something like a 'Play' > 'Stop' button is to have two buttons side by side, with one disabled [grayed-out] if the other one is enabled - using a validation_proc...Or for Play/Stop, just make the Play button pressed or not pressed - using
MF_CHECKED
andMF_UNCHECKED
. -
@thomthom said:
@tig said:
Bum!
The best you could do then for something like a 'Play' > 'Stop' button is to have two buttons side by side, with one disabled [grayed-out] if the other one is enabled - using a validation_proc...Or for Play/Stop, just make the Play button pressed or not pressed - using
MF_CHECKED
andMF_UNCHECKED
.Yeah Thanks!...
This would not be a bad idea.
I think changing toolbar icons should be part of SU 9 wishes. -
I've found this rather old topic, and have a question is it possible now to change toolbar icons.
I would like to change tool icon when some variable (@@active_extension) is changed.
[ruby]@@activateCmd.set_validation_proc(){ puts "Active #{@@active_extension}" puts "before #{@@activateCmd.small_icon}" if @@active_extension == 'ext1' @@activateCmd.small_icon = File.join(icons_dir,"ext1_16.png") @@activateCmd.large_icon = File.join(icons_dir,"ext1_24.png") elseif @@active_extension == 'ext2' @@activateCmd.small_icon = File.join(icons_dir,"ext2_16.png") @@activateCmd.large_icon = File.join(icons_dir,"ext2_24.png") end puts "after #{@@activateCmd.small_icon}" MF_ENABLED }[/ruby]
This part of code validates command and prints correct icon path (which is changed in accordance with @@active_extension variable), but tool image in toolbar is not updated.
I've also tried to put this change not in set_validation_proc(), but in code after variable is changed. Again correct values are printed, but image remains the same.
Thanks in advance,
Marija -
Hi Marija, I just tested changing icons on SU2016, on Windows OS, and it still doesn't work.
-
Thanks Anton,
I was thinking, that I'm doing something wrong, but it seems that this behaviour is not changed yet.
Advertisement