Create toolbar on the fly
-
I'm I correct: it is not possible to create a toolbar from in the ruby console using these command?
toolbar = UI::Toolbar.new "testtoolbar"
cmd = UI::Command.new("testbutton") {a function }
cmd.small_icon = "testimage.png"
cmd.large_icon = "testimage.png"
cmd.tooltip = ("testfunction")
cmd.status_bar_text = ("execute testfunction")
cmd.menu_text = ("execute testfunction")
toolbar = toolbar.add_item cmdThe toolbar is created and listed in the toolbars overview but it is not shown.
-
toolbar.show?
-
@pout said:
I'm I correct: it is not possible to create a toolbar from in the ruby console using these command?
toolbar = UI::Toolbar.new "testtoolbar"
cmd = UI::Command.new("testbutton") {a function }
cmd.small_icon = "testimage.png"
cmd.large_icon = "testimage.png"
cmd.tooltip = ("testfunction")
cmd.status_bar_text = ("execute testfunction")
cmd.menu_text = ("execute testfunction")
toolbar = toolbar.add_item cmd
The toolbar is created and listed in the toolbars overview but it is not shown.Note that 'a function' needs to be a proper function.
The image paths also need to be added to their names.
Trytoolbar.show
to 'show' the toolbar - works for me... -
"crawls in a corner in shame"
Thx! sometimes I can just hit myself
-
@pout said:
Am I correct? Is it not possible to create a toolbar, from in the ruby console, using these commands?
The danger is that the console is running inside Object, and you are using local variables (cmd and toolbar.) Any other 'unwrapped' script that afterward uses the same variable names, will make those 'symbols' point to other UI::Command and UI::Toolbar objects, and you will lose access to them. (Ruby will still know what they are, and the command and toolbar should still work. But you will not be able to make any changes, such as changing the tooltip text.)
IF that's OK, or your just testing, no harm. But if you want later access to your command or toolbar objects, you will need to keep them in unique variable identifiers. For example, you could store them in a Hash.
MyToolbars={'FancyCommand' => cmd, 'PoutTools' => toolbar }
Then later on:
MyToolbars['FancyCommand'].tooltip="Select object before doing something Fancy!"
See this post for more info:
http://forums.sketchucation.com/viewtopic.php?f=180&t=15621&p=220266#p219128
Advertisement