Hello there
For the project i'm coding on these days, i need to create a command, on a toolbar, which toggle another toolbar.
The method get_last_state from the class Toolbar looks convenient for that but i noticed a strange behaviour.
Here is my code for defining my toolbar and the function that toggle the other toolbars.
#here is the function for toggling my toolbar
def toggle(toolbar)
toolbar.show if toolbar.get_last_state == -1
toolbar.show if toolbar.get_last_state == 0
toolbar.hide if toolbar.get_last_state == 1
end
#and then, the block defining my toolbars
main_tb= UI;;Toolbar.new("main toolbar")
cmd= UI;;Command.new("Toggle the second toolbar"){toggle(second_tb)}
cmd.large_icon = cmd.small_icon = File.join(path_to, "maintb.png")
cmd.tooltip = cmd.status_bar_text= "Toggle the second toolbar"
main_tb.add_item cmd
main_tb.show
main_tb= UI;;Toolbar.new("my toolbar")
second_tb= UI;;Toolbar.new("second toolbar")
cmd= UI;;Command.new("hello"){UI.Messagebox("hello")}
cmd.large_icon = cmd.small_icon = File.join(path_to, "secondtb.png")
cmd.tooltip = cmd.status_bar_text= "hello"
second_tb.add_item cmd
But this code works for showing, not for hiding...
hu??
so i checked manually the method get_last_state directly in Sketchup, using the ruby console
I noticed that the value returned by get_last_state never change, whatever i do with show and hide
tb= UI;;Toolbar.new("my toolbar")
#<UI;;Toolbar;0x4b22d08>
cmd= UI;;Command.new("my cmd"){UI.Messagebox("hello")}
#<UI;;Command;0x4b22ae0>
tb.add_item cmd
#<UI;;Toolbar;0x4b22d08>
tb.get_last_state
-1
tb.show
nil
tb.get_last_state
-1
tb.hide
nil
tb.get_last_state
-1
is there a problem with this method?
did i miss something?
thank you for your time