Print at Dec 19, 2025, 9:42:23 PM View all posts in this thread on one page
Posted by Cong at Oct 15, 2013, 6:49:13 PM
confused   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.

Posted by Puybaret at Oct 17, 2013, 9:53:11 PM
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:
((JComponent)getHomeController().getHomeController3D().getView()).getComponentPopupMenu()

----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator

Posted by Cong at Oct 23, 2013, 1:21:13 PM
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.

Posted by Cong at Nov 12, 2013, 6:23:37 PM
Re: Plugin Menus
BUMP

Posted by Cong at Nov 12, 2013, 6:25:30 PM
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.

Posted by Puybaret at Nov 13, 2013, 6:20:41 PM
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 creator

Posted by Cong at Nov 14, 2013, 2:07:03 PM
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.

Posted by Puybaret at Nov 25, 2013, 9:54:18 AM
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 creator

Posted by Cong at Nov 28, 2013, 12:59:20 PM
Re: Plugin Menus
Thank you so much for your help. I have successfully added a few custom options to the JPopupMenu using the method you described in your last post.