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
@playcmdis an class instance variable that only endures during that use of the class.
Making it a@@playcmdclass variable means that it's remembered for that session of Sketchup across instances of the class. You need to declare any such @@'s=nilin 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@statechanging 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@statechanging etc...There's no problem with changing the path to the image (no exception is raised,) it's just that the
UI::Toolbarinstance 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement