Customize Marvin menu/toolbar

User 8b0754eda2

12-10-2006 14:39:22

Hi,





We would like to add a menu item or add a button to the toolbar to Marvin that calls one of our functions. How can we customize the menu or toolbar to do this?





Thanks,





- Suk

ChemAxon a3d59b832c

12-10-2006 14:43:39

I have moved your question to the Marvin forum, where our colleagues will answer soon.

ChemAxon 7c2d26e5cf

16-10-2006 21:14:03

Customization of Marvin menu/toolbar is limited.


You can add extra button to the toolbar. See the following example.


http://www.chemaxon.com/marvin/doc/dev/example-sketch2.html


If you would like to change default template set on the toolbar, you can also change it by defining the tmpls0, tmpls1, etc. parameters. If you use Marvin Beans, you can use the same parameters there, see the following example:


http://www.chemaxon.com/marvin/examples/sketch-customized/SketchCustomized.java.txt


By checking Marvin Beans examples about MarvinView, you can see how to assign a new menu item to the Marvin menu. You can also investigate the code of Sketch application (you can find it among Marvin Beans examples), it can be also useful.


If you describe deeply what you would like to do. I can give you more help.


By the way, we will rewrite Marvin menu. The new menu system will be fully customizeable.

User 8b0754eda2

17-10-2006 13:03:57

We would like to add a button or menu item that will execute a piece of code that will transfer the structure the user drew in Marvin to our software. So we can get either a molfile or smiles string that represents the structure. And I looked at the example you mentioned briefly, but our button is not going to be a structure, the image for the button is probably our custom image, a gif file. We're using Marvin Beans, the MSketchPane class.


You mentioned that the next version of Marvin will allow more customization of menus and toolbar, when is that going to come out?





Thanks,





- Suk

ChemAxon 7c2d26e5cf

21-10-2006 13:08:31

To customize menu: get the menubar of MSketchPane then insert new item into the proper place.


Code:
JMenuBar menubar = sketchPane.getJMenuBar();


JMenu filemenu = menubar.getMenu(0);


JMenuItem newMenu = ...;


filemenu.insert(newMenu, filemenu.getItemCount());



See the code of Sketch.





About toolbar customization: you can paste only molecules/atoms/bonds to the toolbar as extra templates (see wedgebonds template in the following example).


http://www.chemaxon.com/marvin/doc/dev/example-sketch2.html