Intercept UI::Command.new ?
-
Is there a way to intercept
UI.Command.new
so that one can catch the menu_name argument passed to thenew
method ? -
never mind - think I got it working now... I think...
-
Eeeexcellent!
-
@thomthom said:
Is there a way to intercept
UI.Command.new
so that one can catch the menu_name argument passed to thenew
method ?It is possible so:
module Object;;UI class Command class << self alias ;newORIG ;new private ;newORIG end def self.new(m_name, &cmd_block) p m_name #some code... self.__send__(;newORIG, m_name, &cmd_block) end#def end end#module
-
Thom, this looks very intersting. Are you going to post some working code or a plugin here soon?
-
Need some more coding.
I've intercepted all the menus created and added getter methods. With this I should be able to override the menu and toolbar structures. It's all going to take a lot of UI development, but what I'm thinking is:Being able to:
- Override menu & toolbar text, tooltips, statusbar text
- Override menu location (user defined menu structure)
- Custom toolbars of any Ruby toolbar buttons (Though there can be issues here with plugins trying to hide/show their own toolbars)
- Mute menus and toolbar buttons
- Automatic menu sorting or custom arrangement (need to find a good solution for this)
Regarding automatic menu sorting or custom arrangement there are some issues:
Idea 1 - pre-populate the menus and hook up the commands when the plugins loads. Issue here is if a plugin is removed there'll be dead menu items. (Purge menu command?)Idea 2 - Find a way to work out when SU has loaded all plugins upon SU startup - populate menus when they are done.
-
Very interesting. Awaiting your TT_toolbarTool...
Advertisement