Any configuration for my plugin to be visible by default?

I developed a plugin. When my friends installed it, it did not show in toolbar. Instead, I have to right click toolbar to make it visible. My code:

this_file = File.basename(__FILE__)
unless file_loaded?( this_file )
  toolbar = UI::Toolbar.new "My Plugin"

  cmd = UI::Command.new("Myplugin") {
    self.openDashboard()
  }
  cmd.small_icon = "images/cxhk.png"
  cmd.large_icon = "images/cxhk.png"
  cmd.tooltip = "My plugin"
  cmd.status_bar_text = "My plugin"
  cmd.menu_text = "My plugin"
  toolbar = toolbar.add_item cmd
end

Is there any configuration to set the plugin shown by default?

1 Like

Call toolbar.restore and the toolbar will be restored to its previous visibility state, or shown on the first run.

toolbar.restore if toolbar.get_last_state.abs == 1 #TB_VISIBLE || NEVER

Toolbar is visible when code first loads or if the user has not closed it subsequently…

Thanks. I trid toolbar.show. It seems to work. Is it right also?

The Toolbar#show instance_method will always make the toolbar visible. Regardless if the user closed it or not.
This can be confusing for the user who doesn’t want to see it all the time, as she/he probably closed it because she/he doesn’t want to see it …

While the Toolbar#restore instance_method will take the user decision into consideration, and still will show the toolbar at the very first time when the tool installed.

1 Like

Thanks. I got it.