Changing Toolbar Image
-
Lets say I've created a new command:
@toolbar=UI;;Toolbar.new("simulation") @playcmd=UI;;Command.new("play"){simulation.new} @playcmd.small_icon=@playcmd.large_icon="buttons/run.bmp" @playcmd.tooltip="Start simulation" @playcmd.status_bar_text="Start simulation" @playcmd.menu_text="Start!" @toolbar.add_item(@playcmd) @toolbar.show()
Is there a way to change the icon of @playcmd any time I want? >
When I click @playcmd button I wan't its icon to change to different icon. Like at first click the icon changes to pause.bmp, and at second click I want icon to change back to run.bmp. -
The
@playcmd
is an class instance variable that only endures during that use of the class.
Making it a@@playcmd
class variable means that it's remembered for that session of Sketchup across instances of the class. You need to declare any such @@'s=nil
in the body of the class code [near the start] and then set them to refer to objects within your methods etc...
So theoretically you could [re]set the@@playcmd.small_icon()
etc dynamically in response to a user clicking the button and/or the tool's@state
changing etc... -
@tig said:
So theoretically you could [re]set the
@@playcmd.small_icon()
etc dynamically in response to a user clicking the button and/or the tool's@state
changing etc...There's no problem with changing the path to the image (no exception is raised,) it's just that the
UI::Toolbar
instance ignores the change. We've tried closing and opening the toolbar, but no effect.This is a change that needs to be implemented in the API using the relevant system calls on each platform. (I know how to do it on Windows making a Win32 call, but not on Mac.)
So, this is a true wish... add my vote.
Advertisement