Joined: Oct 15, 2013
Post Count: 6
Status:
Offline
Plugin Menus
Is it possible to create plugin functions that appear in the 'right click' menu instead of the main menu at the top? If it is not possible then that is fine and I can work around that but it would make for a friendlier user interface.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Plugin Menus
The JPopupMenu contextual menus are accessible through the getComponentPopupMenu method of the Swing views. So, it should be possible to modify them directly if needed. For example, the following call will return the contextual menu of the 3D view:
Joined: Oct 15, 2013
Post Count: 6
Status:
Offline
Re: Plugin Menus
Thank you so much for your reply. The process you described seems to work but I can only get the menu to appear in the 3D model of the house. When I change getHomeController3D() to getPlanController() a JPopupMenu does not get returned.
Joined: Oct 15, 2013
Post Count: 6
Status:
Offline
Re: Plugin Menus
I'm guessing that the planController gets filled upon a click event so I was wondering how I might add to the plancontroller popup menu without creating a new list.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Plugin Menus
Exploring the code yourself would have given you the answer. In the current version, the view of the plan is an instance of MultipleLevelsPlanPanel class. Exploring the childs of this object will let you find the final PlanComponent that stores the popup menu.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Joined: Oct 15, 2013
Post Count: 6
Status:
Offline
Re: Plugin Menus
I am still confused on how (without changing the source code) I am to access the current popupmenu with a plugin. The code that you linked me to had no @override get call for the popup menu (it has a set). I want to pull the current menu and concatenate onto the end some of my own options so i need to be able to pull the current menu first. Could you possibly elaborate more on how to do this please.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Plugin Menus
The contextual menu is attached to the PlanComponent instance, and you can find that instance with the static method findChildren in SwingTools class. By the way, it would be nice to explain the kind of plug-in you want to develop.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer