Re: [Jmol-users] Jmol | Context Menu for JSmol
Thanks, Bob! I didn't get a chance to test today, but I trust it's working fine. FYI, not sure if this is a first, but my friends and I just toasted Jmol! :-) Cheers, Mike On Monday, December 24, 2012, Robert Hanson wrote: > and, of course > > http://chemapps.stolaf.edu/jmol/jsmol/test2.htm?USE=HTML5 > > > On Sun, Dec 23, 2012 at 11:08 PM, Robert Hanson wrote: > > OK! We have a popup menu in JavaScript. Thank you, Michael Evans!!! jQuery > UI to the rescue. All relevant code is in jsmol/j2s/java/coremenu.js > > > Check it out. http://chemapps.stolaf.edu/jmol/jsmol/test2.htm and > http://chemapps.stolaf.edu/jmol/jsmol.zip > > Right-click for the menu -- not sure about Macs or tablets yet. > > I still need to remove some of the menu items such as Console that do not > relate to JavaScript. > > > > Bob > > > > On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > > Jmol community, > Here's a simple example of a context menu in JSmol: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Dig into the document ready function and jmolPopupMenu.js for details. The > whole kit and kaboodle (including jQueryUI menu, which I used to handle the > visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its > associated functions: > > initializeMenu > menuAddItem(menu, item) > menuRemoveItem(menu, itemId) > menuAddSubmenu(menu, submenu) > menuAddSeparator(menu) > menuEnableItem(menu, itemId, boolEnable) > > Should the "items" sent to menuAddItem, etc. just be HTML, or something > more abstract like Javascript objects? There are no jQueryUI objects for > things like radio groups and checkboxes...these would have to be handled by > us somewhere on the path from abstract menu object to final rendered menu. > Would be interested to hear your thoughts on the best way to implement > addItem. > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Mon > > -- --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
and, of course http://chemapps.stolaf.edu/jmol/jsmol/test2.htm?USE=HTML5 On Sun, Dec 23, 2012 at 11:08 PM, Robert Hanson wrote: > OK! We have a popup menu in JavaScript. Thank you, Michael Evans!!! jQuery > UI to the rescue. All relevant code is in jsmol/j2s/java/coremenu.js > > > Check it out. http://chemapps.stolaf.edu/jmol/jsmol/test2.htm and > http://chemapps.stolaf.edu/jmol/jsmol.zip > > Right-click for the menu -- not sure about Macs or tablets yet. > > I still need to remove some of the menu items such as Console that do not > relate to JavaScript. > > > > Bob > > > > On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > >> Jmol community, >> Here's a simple example of a context menu in JSmol: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Dig into the document ready function and jmolPopupMenu.js for details. >> The whole kit and kaboodle (including jQueryUI menu, which I used to handle >> the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its >> associated functions: >> >> initializeMenu >> menuAddItem(menu, item) >> menuRemoveItem(menu, itemId) >> menuAddSubmenu(menu, submenu) >> menuAddSeparator(menu) >> menuEnableItem(menu, itemId, boolEnable) >> >> Should the "items" sent to menuAddItem, etc. just be HTML, or something >> more abstract like Javascript objects? There are no jQueryUI objects for >> things like radio groups and checkboxes...these would have to be handled by >> us somewhere on the path from abstract menu object to final rendered menu. >> Would be interested to hear your thoughts on the best way to implement >> addItem. >> >> Cheers, Mike >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois, Urbana-Champaign >> >> >> >> -- >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> Remotely access PCs and mobile devices and provide instant support >> Improve your efficiency, and focus on delivering more value-add services >> Discover what IT Professionals Know. Rescue delivers >> http://p.sf.net/sfu/logmein_12329d2d >> ___ >> Jmol-users mailing list >> Jmol-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jmol-users >> >> > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
coremenu.z.js On Tue, Dec 18, 2012 at 2:30 PM, Robert Hanson wrote: > super! > > > > On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > >> Jmol community, >> Here's a simple example of a context menu in JSmol: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Dig into the document ready function and jmolPopupMenu.js for details. >> The whole kit and kaboodle (including jQueryUI menu, which I used to handle >> the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its >> associated functions: >> >> initializeMenu >> menuAddItem(menu, item) >> menuRemoveItem(menu, itemId) >> menuAddSubmenu(menu, submenu) >> menuAddSeparator(menu) >> menuEnableItem(menu, itemId, boolEnable) >> >> Should the "items" sent to menuAddItem, etc. just be HTML, or something >> more abstract like Javascript objects? >> > > These should definitely be objects. I would say something that mirrors > those in the Java system: > > import java.awt.Component; > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; > import java.awt.event.ItemEvent; > import java.awt.event.ItemListener; > import java.awt.event.MouseEvent; > import java.awt.event.MouseListener; > > import javax.swing.AbstractButton; > import javax.swing.ButtonGroup; > import javax.swing.ImageIcon; > import javax.swing.JCheckBoxMenuItem; > import javax.swing.JComponent; > import javax.swing.JMenu; > import javax.swing.JMenuItem; > import javax.swing.JPopupMenu; > import javax.swing.JRadioButtonMenuItem; > > Not saying we have to use all of those, but they are there for a reason, > and every one is accessed in one way or another to set the menus. > > > >> There are no jQueryUI objects for things like radio groups and >> checkboxes...these would have to be handled by us somewhere on the path >> from abstract menu object to final rendered menu. Would be interested to >> hear your thoughts on the best way to implement addItem. >> >> Cheers, Mike >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois, Urbana-Champaign >> >> >> >> -- >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> Remotely access PCs and mobile devices and provide instant support >> Improve your efficiency, and focus on delivering more value-add services >> Discover what IT Professionals Know. Rescue delivers >> http://p.sf.net/sfu/logmein_12329d2d >> ___ >> Jmol-users mailing list >> Jmol-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jmol-users >> >> > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
OK! We have a popup menu in JavaScript. Thank you, Michael Evans!!! jQuery UI to the rescue. All relevant code is in jsmol/j2s/java/coremenu.js Check it out. http://chemapps.stolaf.edu/jmol/jsmol/test2.htm and http://chemapps.stolaf.edu/jmol/jsmol.zip Right-click for the menu -- not sure about Macs or tablets yet. I still need to remove some of the menu items such as Console that do not relate to JavaScript. Bob On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > Jmol community, > Here's a simple example of a context menu in JSmol: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Dig into the document ready function and jmolPopupMenu.js for details. The > whole kit and kaboodle (including jQueryUI menu, which I used to handle the > visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its > associated functions: > > initializeMenu > menuAddItem(menu, item) > menuRemoveItem(menu, itemId) > menuAddSubmenu(menu, submenu) > menuAddSeparator(menu) > menuEnableItem(menu, itemId, boolEnable) > > Should the "items" sent to menuAddItem, etc. just be HTML, or something > more abstract like Javascript objects? There are no jQueryUI objects for > things like radio groups and checkboxes...these would have to be handled by > us somewhere on the path from abstract menu object to final rendered menu. > Would be interested to hear your thoughts on the best way to implement > addItem. > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
ps - in http://chemapps.stolaf.edu/jmol/jsmol/t.htm I have replaced all the display:none with display:block. On Sat, Dec 22, 2012 at 7:44 PM, Robert Hanson wrote: > Michael, I have something for you. Probably almost there. > > http://chemapps.stolaf.edu/jmol/jsmol_menu_test.zip > > Unzip that and run test2.htm?USE=HTML5&debugcode > > After the model loads, right click. You should see the outline of an empty > menu > > JSmol is definitely creating the menu -- I can extract the HTML with > > jmolApplet0._popups["popupMenu"]._menuContainer.html() > > in the developer console -- see > http://chemapps.stolaf.edu/jmol/jsmol/t.htm > > But I don't see how the menu is actually operated. > > I know I left out a bunch of jQuery business. Maybe you can see how to add > it in. > > All the code you sent me is in j2s/java/coremenu.z.js > > This file only loads when the menu is requested. > > The reason for the proto.xxx methods is that it allows me to do something > you cannot do in Java -- basically have multiple inheritance. > > Good luck! > > Bob > > > > On Sat, Dec 22, 2012 at 11:30 AM, Robert Hanson wrote: > >> OK. I'm working on the patch now. >> >> >> On Sat, Dec 22, 2012 at 11:22 AM, Michael Evans wrote: >> >>> Yep, the link below is still the latest. If you can see the radio button >>> group of colors, you know you're looking at the newest version. I've also >>> just implemented ImageIcon. >>> >>> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >>> >>> Cheers, Mike >>> >>> >>> --- >>> Michael Evans >>> Organic Chemistry Graduate Student, Moore Group >>> University of Illinois, Urbana-Champaign >>> >>> >>> On Sat, Dec 22, 2012 at 10:43 AM, Robert Hanson wrote: >>> On Sat, Dec 22, 2012 at 12:56 AM, Michael Evans wrote: > Getting quite close. Buttons (menu items), checkboxes, radio buttons, > and button groups are all working with proper event handling (FYI, event > handling requires jQuery >1.7, which JSmol appears to be using, but just a > heads up for those who might wish to "downgrade" jQuery for some reason. > Hope this is OK). > JSmol is using an adapted (by me) version of jQuery that includes synchronous binary file transfer. Users are strongly discouraged from "downgrading" > > Figuring out when exactly to bind handlers to click and change events > was a little tricky, but I think I've got it down. It happens in the > PopupMenu.addItem and SubMenu.addItem functions, after the HTML of the > item > has been added to the page's DOM. I think this is a little different from > the way addItemListener and addActionListener work in Java...but the same > effect is achieved. > > Some questions that remain: > > - What's an ImageIcon? Could I get an example in the current context > menu for Jmol (Java)? Same question for AbstractButton and JComponent. If > my poor memory of Java serves me right, JComponent is a very "low-level" > class in Swing. Once those three are implemented, all the objects you > listed will have JS equivalents, Bob. > The ModelKit menu places an image in each of the three main menu items. It's just an tag in this case. > - Still not seeing how to wire my setup to the > org.awtjs2d.Platform.getMenuPopup function. I dig into Platform.js and all > I see is a line of code that sets the function to null...*Nevermind, > I have an old version of JSmol on my server :-D* Still don't really > see how to actually call that function and use what it returns, though. > Can't find it in the Jmol object or in the applet's instance object. > > I'll do that today. Presuming the link below is the latest Bob > Cheers, Mike > > > On Friday, December 21, 2012, Bob Hanson wrote: > >> What's the latest? I'd like to test this some tomorrow. >> >> Sent from my stupid iPhone >> >> On Dec 19, 2012, at 5:56 PM, Michael Evans >> wrote: >> >> Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy >> fix. The array.splice(indexToStart, numberOfElements) function is perfect >> for it. Now fixed; see the new method below. >> >> menuRemoveItem: function(menu, index) { >> if(index >= 0 && index < menu.items.length) >> menu.items.splice(index, 1); >> } >> >> I see what you mean about the action listener, Bob. Shouldn't be too >> tough to make that happen. Thanks for the debugCode tip; should be easier >> to get a handle on that now as well. Finally, feel free to copy over any >> or >> all of my code to the "official" JSmol code (probably don't have to tell >> you that... :D). >> >> Cheers, Mike >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois,
Re: [Jmol-users] Jmol | Context Menu for JSmol
Michael, I have something for you. Probably almost there. http://chemapps.stolaf.edu/jmol/jsmol_menu_test.zip Unzip that and run test2.htm?USE=HTML5&debugcode After the model loads, right click. You should see the outline of an empty menu JSmol is definitely creating the menu -- I can extract the HTML with jmolApplet0._popups["popupMenu"]._menuContainer.html() in the developer console -- see http://chemapps.stolaf.edu/jmol/jsmol/t.htm But I don't see how the menu is actually operated. I know I left out a bunch of jQuery business. Maybe you can see how to add it in. All the code you sent me is in j2s/java/coremenu.z.js This file only loads when the menu is requested. The reason for the proto.xxx methods is that it allows me to do something you cannot do in Java -- basically have multiple inheritance. Good luck! Bob On Sat, Dec 22, 2012 at 11:30 AM, Robert Hanson wrote: > OK. I'm working on the patch now. > > > On Sat, Dec 22, 2012 at 11:22 AM, Michael Evans wrote: > >> Yep, the link below is still the latest. If you can see the radio button >> group of colors, you know you're looking at the newest version. I've also >> just implemented ImageIcon. >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Cheers, Mike >> >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois, Urbana-Champaign >> >> >> On Sat, Dec 22, 2012 at 10:43 AM, Robert Hanson wrote: >> >>> >>> >>> >>> On Sat, Dec 22, 2012 at 12:56 AM, Michael Evans wrote: >>> Getting quite close. Buttons (menu items), checkboxes, radio buttons, and button groups are all working with proper event handling (FYI, event handling requires jQuery >1.7, which JSmol appears to be using, but just a heads up for those who might wish to "downgrade" jQuery for some reason. Hope this is OK). >>> >>> JSmol is using an adapted (by me) version of jQuery that includes >>> synchronous binary file transfer. Users are strongly discouraged from >>> "downgrading" >>> >>> Figuring out when exactly to bind handlers to click and change events was a little tricky, but I think I've got it down. It happens in the PopupMenu.addItem and SubMenu.addItem functions, after the HTML of the item has been added to the page's DOM. I think this is a little different from the way addItemListener and addActionListener work in Java...but the same effect is achieved. Some questions that remain: - What's an ImageIcon? Could I get an example in the current context menu for Jmol (Java)? Same question for AbstractButton and JComponent. If my poor memory of Java serves me right, JComponent is a very "low-level" class in Swing. Once those three are implemented, all the objects you listed will have JS equivalents, Bob. >>> >>> The ModelKit menu places an image in each of the three main menu items. >>> It's just an tag in this case. >>> >>> >>> - Still not seeing how to wire my setup to the org.awtjs2d.Platform.getMenuPopup function. I dig into Platform.js and all I see is a line of code that sets the function to null...*Nevermind, I have an old version of JSmol on my server :-D* Still don't really see how to actually call that function and use what it returns, though. Can't find it in the Jmol object or in the applet's instance object. >>> I'll do that today. >>> >>> Presuming the link below is the latest >>> >>> Bob >>> >>> >>> Cheers, Mike On Friday, December 21, 2012, Bob Hanson wrote: > What's the latest? I'd like to test this some tomorrow. > > Sent from my stupid iPhone > > On Dec 19, 2012, at 5:56 PM, Michael Evans > wrote: > > Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy > fix. The array.splice(indexToStart, numberOfElements) function is perfect > for it. Now fixed; see the new method below. > > menuRemoveItem: function(menu, index) { > if(index >= 0 && index < menu.items.length) > menu.items.splice(index, 1); > } > > I see what you mean about the action listener, Bob. Shouldn't be too > tough to make that happen. Thanks for the debugCode tip; should be easier > to get a handle on that now as well. Finally, feel free to copy over any > or > all of my code to the "official" JSmol code (probably don't have to tell > you that... :D). > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: > > Wow, this is great! Almost there, I think. > > > On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans > wrote: > > Bob et al., > Progress has been made on a popup menu for JSmol. I've implemented > PopupMenu, MenuIt
Re: [Jmol-users] Jmol | Context Menu for JSmol
OK. I'm working on the patch now. On Sat, Dec 22, 2012 at 11:22 AM, Michael Evans wrote: > Yep, the link below is still the latest. If you can see the radio button > group of colors, you know you're looking at the newest version. I've also > just implemented ImageIcon. > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Cheers, Mike > > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > On Sat, Dec 22, 2012 at 10:43 AM, Robert Hanson wrote: > >> >> >> >> On Sat, Dec 22, 2012 at 12:56 AM, Michael Evans wrote: >> >>> Getting quite close. Buttons (menu items), checkboxes, radio buttons, >>> and button groups are all working with proper event handling (FYI, event >>> handling requires jQuery >1.7, which JSmol appears to be using, but just a >>> heads up for those who might wish to "downgrade" jQuery for some reason. >>> Hope this is OK). >>> >> >> JSmol is using an adapted (by me) version of jQuery that includes >> synchronous binary file transfer. Users are strongly discouraged from >> "downgrading" >> >> >>> >>> Figuring out when exactly to bind handlers to click and change events >>> was a little tricky, but I think I've got it down. It happens in the >>> PopupMenu.addItem and SubMenu.addItem functions, after the HTML of the item >>> has been added to the page's DOM. I think this is a little different from >>> the way addItemListener and addActionListener work in Java...but the same >>> effect is achieved. >>> >>> Some questions that remain: >>> >>> - What's an ImageIcon? Could I get an example in the current context >>> menu for Jmol (Java)? Same question for AbstractButton and JComponent. If >>> my poor memory of Java serves me right, JComponent is a very "low-level" >>> class in Swing. Once those three are implemented, all the objects you >>> listed will have JS equivalents, Bob. >>> >> >> The ModelKit menu places an image in each of the three main menu items. >> It's just an tag in this case. >> >> >> >>> - Still not seeing how to wire my setup to the >>> org.awtjs2d.Platform.getMenuPopup function. I dig into Platform.js and all >>> I see is a line of code that sets the function to null...*Nevermind, I >>> have an old version of JSmol on my server :-D* Still don't really see >>> how to actually call that function and use what it returns, though. Can't >>> find it in the Jmol object or in the applet's instance object. >>> >>> >> I'll do that today. >> >> Presuming the link below is the latest >> >> Bob >> >> >> >>> Cheers, Mike >>> >>> >>> On Friday, December 21, 2012, Bob Hanson wrote: >>> What's the latest? I'd like to test this some tomorrow. Sent from my stupid iPhone On Dec 19, 2012, at 5:56 PM, Michael Evans wrote: Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy fix. The array.splice(indexToStart, numberOfElements) function is perfect for it. Now fixed; see the new method below. menuRemoveItem: function(menu, index) { if(index >= 0 && index < menu.items.length) menu.items.splice(index, 1); } I see what you mean about the action listener, Bob. Shouldn't be too tough to make that happen. Thanks for the debugCode tip; should be easier to get a handle on that now as well. Finally, feel free to copy over any or all of my code to the "official" JSmol code (probably don't have to tell you that... :D). Cheers, Mike --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: Wow, this is great! Almost there, I think. On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: Bob et al., Progress has been made on a popup menu for JSmol. I've implemented PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other things. Check it out: http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js OK! You are way ahead of me! The demo is still functional as well: http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html Two things I'm struggling with: 1) What's the difference between a ButtonGroup and a set of RadioButtonMenuItems? I think it's the same. I think really in JavaScript it's just a set of radio buttons with the same name. Be sure to use applet._id as a prefix to every name or id so that multiple applets on a page do not have the same name or id for anything. 2) Event handling in general. For example, a checkbox menu item doesn't "know" its parent, so when it's clicked, it can't run commands on its parent applet without bubbling an event up to its parent jmol object >>> >>>
Re: [Jmol-users] Jmol | Context Menu for JSmol
Yep, the link below is still the latest. If you can see the radio button group of colors, you know you're looking at the newest version. I've also just implemented ImageIcon. http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html Cheers, Mike --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign On Sat, Dec 22, 2012 at 10:43 AM, Robert Hanson wrote: > > > > On Sat, Dec 22, 2012 at 12:56 AM, Michael Evans wrote: > >> Getting quite close. Buttons (menu items), checkboxes, radio buttons, and >> button groups are all working with proper event handling (FYI, event >> handling requires jQuery >1.7, which JSmol appears to be using, but just a >> heads up for those who might wish to "downgrade" jQuery for some reason. >> Hope this is OK). >> > > JSmol is using an adapted (by me) version of jQuery that includes > synchronous binary file transfer. Users are strongly discouraged from > "downgrading" > > >> >> Figuring out when exactly to bind handlers to click and change events was >> a little tricky, but I think I've got it down. It happens in the >> PopupMenu.addItem and SubMenu.addItem functions, after the HTML of the item >> has been added to the page's DOM. I think this is a little different from >> the way addItemListener and addActionListener work in Java...but the same >> effect is achieved. >> >> Some questions that remain: >> >> - What's an ImageIcon? Could I get an example in the current context menu >> for Jmol (Java)? Same question for AbstractButton and JComponent. If my >> poor memory of Java serves me right, JComponent is a very "low-level" class >> in Swing. Once those three are implemented, all the objects you listed will >> have JS equivalents, Bob. >> > > The ModelKit menu places an image in each of the three main menu items. > It's just an tag in this case. > > > >> - Still not seeing how to wire my setup to the >> org.awtjs2d.Platform.getMenuPopup function. I dig into Platform.js and all >> I see is a line of code that sets the function to null...*Nevermind, I >> have an old version of JSmol on my server :-D* Still don't really see >> how to actually call that function and use what it returns, though. Can't >> find it in the Jmol object or in the applet's instance object. >> >> > I'll do that today. > > Presuming the link below is the latest > > Bob > > > >> Cheers, Mike >> >> >> On Friday, December 21, 2012, Bob Hanson wrote: >> >>> What's the latest? I'd like to test this some tomorrow. >>> >>> Sent from my stupid iPhone >>> >>> On Dec 19, 2012, at 5:56 PM, Michael Evans wrote: >>> >>> Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy fix. >>> The array.splice(indexToStart, numberOfElements) function is perfect for >>> it. Now fixed; see the new method below. >>> >>> menuRemoveItem: function(menu, index) { >>> if(index >= 0 && index < menu.items.length) >>> menu.items.splice(index, 1); >>> } >>> >>> I see what you mean about the action listener, Bob. Shouldn't be too >>> tough to make that happen. Thanks for the debugCode tip; should be easier >>> to get a handle on that now as well. Finally, feel free to copy over any or >>> all of my code to the "official" JSmol code (probably don't have to tell >>> you that... :D). >>> >>> Cheers, Mike >>> >>> --- >>> Michael Evans >>> Organic Chemistry Graduate Student, Moore Group >>> University of Illinois, Urbana-Champaign >>> >>> >>> On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: >>> >>> Wow, this is great! Almost there, I think. >>> >>> >>> On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: >>> >>> Bob et al., >>> Progress has been made on a popup menu for JSmol. I've implemented >>> PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other >>> things. Check it out: >>> >>> http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js >>> >>> >>> OK! You are way ahead of me! >>> >>> >>> >>> The demo is still functional as well: >>> >>> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >>> >>> Two things I'm struggling with: >>> 1) What's the difference between a ButtonGroup and a set of >>> RadioButtonMenuItems? >>> >>> >>> I think it's the same. I think really in JavaScript it's just a set of >>> radio buttons with the same name. Be sure to use >>> >>> applet._id >>> >>> as a prefix to every name or id so that multiple applets on a page do >>> not have the same name or id for anything. >>> >>> >>> >>> 2) Event handling in general. For example, a checkbox menu item doesn't >>> "know" its parent, so when it's clicked, it can't run commands on its >>> parent applet without bubbling an event up to its parent jmol object >>> >>> >> >> -- >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> Remotely access PCs and mobile devices and provide instant support >> Improve your efficiency, and focus on de
Re: [Jmol-users] Jmol | Context Menu for JSmol
On Sat, Dec 22, 2012 at 12:56 AM, Michael Evans wrote: > Getting quite close. Buttons (menu items), checkboxes, radio buttons, and > button groups are all working with proper event handling (FYI, event > handling requires jQuery >1.7, which JSmol appears to be using, but just a > heads up for those who might wish to "downgrade" jQuery for some reason. > Hope this is OK). > JSmol is using an adapted (by me) version of jQuery that includes synchronous binary file transfer. Users are strongly discouraged from "downgrading" > > Figuring out when exactly to bind handlers to click and change events was > a little tricky, but I think I've got it down. It happens in the > PopupMenu.addItem and SubMenu.addItem functions, after the HTML of the item > has been added to the page's DOM. I think this is a little different from > the way addItemListener and addActionListener work in Java...but the same > effect is achieved. > > Some questions that remain: > > - What's an ImageIcon? Could I get an example in the current context menu > for Jmol (Java)? Same question for AbstractButton and JComponent. If my > poor memory of Java serves me right, JComponent is a very "low-level" class > in Swing. Once those three are implemented, all the objects you listed will > have JS equivalents, Bob. > The ModelKit menu places an image in each of the three main menu items. It's just an tag in this case. > - Still not seeing how to wire my setup to the > org.awtjs2d.Platform.getMenuPopup function. I dig into Platform.js and all > I see is a line of code that sets the function to null...*Nevermind, I > have an old version of JSmol on my server :-D* Still don't really see how > to actually call that function and use what it returns, though. Can't find > it in the Jmol object or in the applet's instance object. > > I'll do that today. Presuming the link below is the latest Bob > Cheers, Mike > > > On Friday, December 21, 2012, Bob Hanson wrote: > >> What's the latest? I'd like to test this some tomorrow. >> >> Sent from my stupid iPhone >> >> On Dec 19, 2012, at 5:56 PM, Michael Evans wrote: >> >> Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy fix. >> The array.splice(indexToStart, numberOfElements) function is perfect for >> it. Now fixed; see the new method below. >> >> menuRemoveItem: function(menu, index) { >> if(index >= 0 && index < menu.items.length) >> menu.items.splice(index, 1); >> } >> >> I see what you mean about the action listener, Bob. Shouldn't be too >> tough to make that happen. Thanks for the debugCode tip; should be easier >> to get a handle on that now as well. Finally, feel free to copy over any or >> all of my code to the "official" JSmol code (probably don't have to tell >> you that... :D). >> >> Cheers, Mike >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois, Urbana-Champaign >> >> >> On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: >> >> Wow, this is great! Almost there, I think. >> >> >> On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: >> >> Bob et al., >> Progress has been made on a popup menu for JSmol. I've implemented >> PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other >> things. Check it out: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js >> >> >> OK! You are way ahead of me! >> >> >> >> The demo is still functional as well: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Two things I'm struggling with: >> 1) What's the difference between a ButtonGroup and a set of >> RadioButtonMenuItems? >> >> >> I think it's the same. I think really in JavaScript it's just a set of >> radio buttons with the same name. Be sure to use >> >> applet._id >> >> as a prefix to every name or id so that multiple applets on a page do not >> have the same name or id for anything. >> >> >> >> 2) Event handling in general. For example, a checkbox menu item doesn't >> "know" its parent, so when it's clicked, it can't run commands on its >> parent applet without bubbling an event up to its parent jmol object >> >> > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lectu
Re: [Jmol-users] Jmol | Context Menu for JSmol
Getting quite close. Buttons (menu items), checkboxes, radio buttons, and button groups are all working with proper event handling (FYI, event handling requires jQuery >1.7, which JSmol appears to be using, but just a heads up for those who might wish to "downgrade" jQuery for some reason. Hope this is OK). Figuring out when exactly to bind handlers to click and change events was a little tricky, but I think I've got it down. It happens in the PopupMenu.addItem and SubMenu.addItem functions, after the HTML of the item has been added to the page's DOM. I think this is a little different from the way addItemListener and addActionListener work in Java...but the same effect is achieved. Some questions that remain: - What's an ImageIcon? Could I get an example in the current context menu for Jmol (Java)? Same question for AbstractButton and JComponent. If my poor memory of Java serves me right, JComponent is a very "low-level" class in Swing. Once those three are implemented, all the objects you listed will have JS equivalents, Bob. - Still not seeing how to wire my setup to the org.awtjs2d.Platform.getMenuPopup function. I dig into Platform.js and all I see is a line of code that sets the function to null...*Nevermind, I have an old version of JSmol on my server :-D* Still don't really see how to actually call that function and use what it returns, though. Can't find it in the Jmol object or in the applet's instance object. Cheers, Mike On Friday, December 21, 2012, Bob Hanson wrote: > What's the latest? I'd like to test this some tomorrow. > > Sent from my stupid iPhone > > On Dec 19, 2012, at 5:56 PM, Michael Evans wrote: > > Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy fix. > The array.splice(indexToStart, numberOfElements) function is perfect for > it. Now fixed; see the new method below. > > menuRemoveItem: function(menu, index) { > if(index >= 0 && index < menu.items.length) > menu.items.splice(index, 1); > } > > I see what you mean about the action listener, Bob. Shouldn't be too tough > to make that happen. Thanks for the debugCode tip; should be easier to get > a handle on that now as well. Finally, feel free to copy over any or all of > my code to the "official" JSmol code (probably don't have to tell you > that... :D). > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: > > Wow, this is great! Almost there, I think. > > > On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: > > Bob et al., > Progress has been made on a popup menu for JSmol. I've implemented > PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other > things. Check it out: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js > > > OK! You are way ahead of me! > > > > The demo is still functional as well: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Two things I'm struggling with: > 1) What's the difference between a ButtonGroup and a set of > RadioButtonMenuItems? > > > I think it's the same. I think really in JavaScript it's just a set of > radio buttons with the same name. Be sure to use > > applet._id > > as a prefix to every name or id so that multiple applets on a page do not > have the same name or id for anything. > > > > 2) Event handling in general. For example, a checkbox menu item doesn't > "know" its parent, so when it's clicked, it can't run commands on its > parent applet without bubbling an event up to its parent jmol object > > -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
What's the latest? I'd like to test this some tomorrow. Sent from my stupid iPhone On Dec 19, 2012, at 5:56 PM, Michael Evans wrote: > Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy fix. The > array.splice(indexToStart, numberOfElements) function is perfect for it. Now > fixed; see the new method below. > > menuRemoveItem: function(menu, index) { > if(index >= 0 && index < menu.items.length) > menu.items.splice(index, 1); > } > > I see what you mean about the action listener, Bob. Shouldn't be too tough to > make that happen. Thanks for the debugCode tip; should be easier to get a > handle on that now as well. Finally, feel free to copy over any or all of my > code to the "official" JSmol code (probably don't have to tell you that... > :D). > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: > Wow, this is great! Almost there, I think. > > > On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: > Bob et al., > Progress has been made on a popup menu for JSmol. I've implemented PopupMenu, > MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other things. > Check it out: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js > > > OK! You are way ahead of me! > > > The demo is still functional as well: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Two things I'm struggling with: > 1) What's the difference between a ButtonGroup and a set of > RadioButtonMenuItems? > > I think it's the same. I think really in JavaScript it's just a set of radio > buttons with the same name. Be sure to use > > applet._id > > as a prefix to every name or id so that multiple applets on a page do not > have the same name or id for anything. > > > 2) Event handling in general. For example, a checkbox menu item doesn't > "know" its parent, so when it's clicked, it can't run commands on its parent > applet without bubbling an event up to its parent jmol object. I will > continue to work on this, but event handling in JS is not one of my > specialties. I'll look into custom events mediated by jQuery, but in the > meantime, if there are any JS event experts out there, help would be > appreciated! :-) > > Actually, it does. What you are missing is that when a checkbox is created, > the following command sequence is run: > > /** > * @j2sNative > * > * if (isRadio) { > *item = new Jmol.Menu.RadioButtonMenuItem(entry); > *item.setArmed(state); > * } else { > *item = new Jmol.Menu.CheckBoxMenuItem(entry); > *item.setState(state); > * } > * item.setSelected(state); > * item.addItemListener(this); > * > */ > > So that "addItemListener" is giving the checkbox a reference to the instance > of org.jmol.awt2d.JSPopup that created it. Store that as jmolPopup in the > item. Then: > > .jmolPopup.checkBoxStateChanged(); > > Similarly, all normal menu items have: > > /** > * @j2sNative > * > * item = new Jmol.Menu.MenuItem(entry); > * item.addActionListener(this); > * > */ > > (notice "Action" here, not "Item") > This is going to respond to clicks: > > .jmolPopup.checkMenuClick(, .getActionCommand()); > > > where getActionCommand() returns "background yellow" should take care of it. > > Finally, there are a few items that are special and start with "Focus". These > also get a mouse listener so that we can track when they are entered and > exited: > >/** > * @j2sNative > *if (id != null && id.startsWith("Focus")) { > * item.addMouseListener(this); > * id = menu.getName() + "." + id; > *} > *item.setName(id == null ? menu.getName() + "." : id); > */ > > Then that needs to be set up so that we can run: > >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > true); >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > false); > > And we should be done! > > > By the way, your comment there that it should be OK to use a null instead of > removing an item is not right. This could happen extensively, and we need to > actually remove that array element. > > Bob > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > > -
Re: [Jmol-users] Jmol | Context Menu for JSmol
clicking on the JSmol logo should do it (when we get this working) On Wed, Dec 19, 2012 at 4:11 PM, Greeves, Nick wrote: > This is a good point. Nothing I try brings up the menu on iPad 2. Works > on Mac OS. > All the best > Nick > -- > 3D Organic Animations http://www.chemtube3d.com > Tel: +44 (0)151-794-3506 (3500 secretary) > > > > On 19 Dec 2012, at 21:36, jmol-users-requ...@lists.sourceforge.net wrote: > > Date: Wed, 19 Dec 2012 16:34:46 -0500 > From: Philip Bays > Subject: Re: [Jmol-users] Jmol | Context Menu for JSmol > To: "jmol-users@lists.sourceforge.net" > > Message-ID: <27ed7644-63f6-4ba4-b56c-812c43d89...@saintmarys.edu> > Content-Type: text/plain; charset="us-ascii" > > How does this work on a tablet or my new iPhone where there is not a > keyboard to activate the menu? > > > Philip Bays > Saint Mary's College > Notre Dame, IN 46556 > > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
Guess I was feeling lazy when I wrote menuRemoveItem...it's an easy fix. The array.splice(indexToStart, numberOfElements) function is perfect for it. Now fixed; see the new method below. menuRemoveItem: function(menu, index) { if(index >= 0 && index < menu.items.length) menu.items.splice(index, 1); } I see what you mean about the action listener, Bob. Shouldn't be too tough to make that happen. Thanks for the debugCode tip; should be easier to get a handle on that now as well. Finally, feel free to copy over any or all of my code to the "official" JSmol code (probably don't have to tell you that... :D). Cheers, Mike --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign On Wed, Dec 19, 2012 at 3:05 PM, Robert Hanson wrote: > Wow, this is great! Almost there, I think. > > > On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: > >> Bob et al., >> Progress has been made on a popup menu for JSmol. I've implemented >> PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other >> things. Check it out: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js >> >> > OK! You are way ahead of me! > > > >> The demo is still functional as well: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Two things I'm struggling with: >> 1) What's the difference between a ButtonGroup and a set of >> RadioButtonMenuItems? >> > > I think it's the same. I think really in JavaScript it's just a set of > radio buttons with the same name. Be sure to use > > applet._id > > as a prefix to every name or id so that multiple applets on a page do not > have the same name or id for anything. > > > >> 2) Event handling in general. For example, a checkbox menu item doesn't >> "know" its parent, so when it's clicked, it can't run commands on its >> parent applet without bubbling an event up to its parent jmol object. I >> will continue to work on this, but event handling in JS is not one of my >> specialties. I'll look into custom events mediated by jQuery, but in the >> meantime, if there are any JS event experts out there, help would be >> appreciated! :-) >> > > Actually, it does. What you are missing is that when a checkbox is > created, the following command sequence is run: > > /** > * @j2sNative > * > * if (isRadio) { > *item = new Jmol.Menu.RadioButtonMenuItem(entry); > *item.setArmed(state); > * } else { > *item = new Jmol.Menu.CheckBoxMenuItem(entry); > *item.setState(state); > * } > * item.setSelected(state); > * item.addItemListener(this); > * > */ > > So that "addItemListener" is giving the checkbox a reference to the > instance of org.jmol.awt2d.JSPopup that created it. Store that as jmolPopup > in the item. Then: > > .jmolPopup.checkBoxStateChanged(); > > Similarly, all normal menu items have: > > /** > * @j2sNative > * > * item = new Jmol.Menu.MenuItem(entry); > * item.addActionListener(this); > * > */ > > (notice "Action" here, not "Item") > This is going to respond to clicks: > > .jmolPopup.checkMenuClick(, .getActionCommand()); > > > where getActionCommand() returns "background yellow" should take care of > it. > > Finally, there are a few items that are special and start with "Focus". > These also get a mouse listener so that we can track when they are entered > and exited: > >/** > * @j2sNative > *if (id != null && id.startsWith("Focus")) { > * item.addMouseListener(this); > * id = menu.getName() + "." + id; > *} > *item.setName(id == null ? menu.getName() + "." : id); > */ > > Then that needs to be set up so that we can run: > >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > true); >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > false); > > And we should be done! > > > By the way, your comment there that it should be OK to use a null instead > of removing an item is not right. This could happen extensively, and we > need to actually remove that array element. > > Bob > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf
[Jmol-users] Jmol | Context Menu for JSmol
This is a good point. Nothing I try brings up the menu on iPad 2. Works on Mac OS. All the best Nick -- 3D Organic Animations http://www.chemtube3d.com Tel: +44 (0)151-794-3506 (3500 secretary) On 19 Dec 2012, at 21:36, jmol-users-requ...@lists.sourceforge.net<mailto:jmol-users-requ...@lists.sourceforge.net> wrote: Date: Wed, 19 Dec 2012 16:34:46 -0500 From: Philip Bays mailto:pb...@saintmarys.edu>> Subject: Re: [Jmol-users] Jmol | Context Menu for JSmol To: "jmol-users@lists.sourceforge.net<mailto:jmol-users@lists.sourceforge.net>" mailto:jmol-users@lists.sourceforge.net>> Message-ID: <27ed7644-63f6-4ba4-b56c-812c43d89...@saintmarys.edu<mailto:b56c-812c43d89...@saintmarys.edu>> Content-Type: text/plain; charset="us-ascii" How does this work on a tablet or my new iPhone where there is not a keyboard to activate the menu? Philip Bays Saint Mary's College Notre Dame, IN 46556 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
Great question, Phil...perhaps a left-click on the JSmol frank a la Jmol would work? --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign On Wed, Dec 19, 2012 at 3:34 PM, Philip Bays wrote: > How does this work on a tablet or my new iPhone where there is not a > keyboard to activate the menu? > > > Philip Bays > Saint Mary's College > Notre Dame, IN 46556 > > Sent from my iPhone > > > > On Dec 19, 2012, at 4:05 PM, Robert Hanson wrote: > > Wow, this is great! Almost there, I think. > > > On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: > >> Bob et al., >> Progress has been made on a popup menu for JSmol. I've implemented >> PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other >> things. Check it out: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js >> >> > OK! You are way ahead of me! > > > >> The demo is still functional as well: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Two things I'm struggling with: >> 1) What's the difference between a ButtonGroup and a set of >> RadioButtonMenuItems? >> > > I think it's the same. I think really in JavaScript it's just a set of > radio buttons with the same name. Be sure to use > > applet._id > > as a prefix to every name or id so that multiple applets on a page do not > have the same name or id for anything. > > > >> 2) Event handling in general. For example, a checkbox menu item doesn't >> "know" its parent, so when it's clicked, it can't run commands on its >> parent applet without bubbling an event up to its parent jmol object. I >> will continue to work on this, but event handling in JS is not one of my >> specialties. I'll look into custom events mediated by jQuery, but in the >> meantime, if there are any JS event experts out there, help would be >> appreciated! :-) >> > > Actually, it does. What you are missing is that when a checkbox is > created, the following command sequence is run: > > /** > * @j2sNative > * > * if (isRadio) { > *item = new Jmol.Menu.RadioButtonMenuItem(entry); > *item.setArmed(state); > * } else { > *item = new Jmol.Menu.CheckBoxMenuItem(entry); > *item.setState(state); > * } > * item.setSelected(state); > * item.addItemListener(this); > * > */ > > So that "addItemListener" is giving the checkbox a reference to the > instance of org.jmol.awt2d.JSPopup that created it. Store that as jmolPopup > in the item. Then: > > .jmolPopup.checkBoxStateChanged(); > > Similarly, all normal menu items have: > > /** > * @j2sNative > * > * item = new Jmol.Menu.MenuItem(entry); > * item.addActionListener(this); > * > */ > > (notice "Action" here, not "Item") > This is going to respond to clicks: > > .jmolPopup.checkMenuClick(, .getActionCommand()); > > > where getActionCommand() returns "background yellow" should take care of > it. > > Finally, there are a few items that are special and start with "Focus". > These also get a mouse listener so that we can track when they are entered > and exited: > >/** > * @j2sNative > *if (id != null && id.startsWith("Focus")) { > * item.addMouseListener(this); > * id = menu.getName() + "." + id; > *} > *item.setName(id == null ? menu.getName() + "." : id); > */ > > Then that needs to be set up so that we can run: > >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > true); >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > false); > > And we should be done! > > > By the way, your comment there that it should be OK to use a null instead > of removing an item is not right. This could happen extensively, and we > need to actually remove that array element. > > Bob > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > > > -- > LogMeI
Re: [Jmol-users] Jmol | Context Menu for JSmol
How does this work on a tablet or my new iPhone where there is not a keyboard to activate the menu? Philip Bays Saint Mary's College Notre Dame, IN 46556 Sent from my iPhone On Dec 19, 2012, at 4:05 PM, Robert Hanson wrote: > Wow, this is great! Almost there, I think. > > > On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: >> Bob et al., >> Progress has been made on a popup menu for JSmol. I've implemented >> PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other >> things. Check it out: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js > > OK! You are way ahead of me! > > >> The demo is still functional as well: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Two things I'm struggling with: >> 1) What's the difference between a ButtonGroup and a set of >> RadioButtonMenuItems? > > I think it's the same. I think really in JavaScript it's just a set of radio > buttons with the same name. Be sure to use > > applet._id > > as a prefix to every name or id so that multiple applets on a page do not > have the same name or id for anything. > > >> 2) Event handling in general. For example, a checkbox menu item doesn't >> "know" its parent, so when it's clicked, it can't run commands on its parent >> applet without bubbling an event up to its parent jmol object. I will >> continue to work on this, but event handling in JS is not one of my >> specialties. I'll look into custom events mediated by jQuery, but in the >> meantime, if there are any JS event experts out there, help would be >> appreciated! :-) > > Actually, it does. What you are missing is that when a checkbox is created, > the following command sequence is run: > > /** > * @j2sNative > * > * if (isRadio) { > *item = new Jmol.Menu.RadioButtonMenuItem(entry); > *item.setArmed(state); > * } else { > *item = new Jmol.Menu.CheckBoxMenuItem(entry); > *item.setState(state); > * } > * item.setSelected(state); > * item.addItemListener(this); > * > */ > > So that "addItemListener" is giving the checkbox a reference to the instance > of org.jmol.awt2d.JSPopup that created it. Store that as jmolPopup in the > item. Then: > > .jmolPopup.checkBoxStateChanged(); > > Similarly, all normal menu items have: > > /** > * @j2sNative > * > * item = new Jmol.Menu.MenuItem(entry); > * item.addActionListener(this); > * > */ > > (notice "Action" here, not "Item") > This is going to respond to clicks: > > .jmolPopup.checkMenuClick(, .getActionCommand()); > > > where getActionCommand() returns "background yellow" should take care of it. > > Finally, there are a few items that are special and start with "Focus". These > also get a mouse listener so that we can track when they are entered and > exited: > >/** > * @j2sNative > *if (id != null && id.startsWith("Focus")) { > * item.addMouseListener(this); > * id = menu.getName() + "." + id; > *} > *item.setName(id == null ? menu.getName() + "." : id); > */ > > Then that needs to be set up so that we can run: > >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > true); >item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), > false); > > And we should be done! > > > By the way, your comment there that it should be OK to use a null instead of > removing an item is not right. This could happen extensively, and we need to > actually remove that array element. > > Bob > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Profe
Re: [Jmol-users] Jmol | Context Menu for JSmol
Wow, this is great! Almost there, I think. On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans wrote: > Bob et al., > Progress has been made on a popup menu for JSmol. I've implemented > PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other > things. Check it out: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js > > OK! You are way ahead of me! > The demo is still functional as well: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Two things I'm struggling with: > 1) What's the difference between a ButtonGroup and a set of > RadioButtonMenuItems? > I think it's the same. I think really in JavaScript it's just a set of radio buttons with the same name. Be sure to use applet._id as a prefix to every name or id so that multiple applets on a page do not have the same name or id for anything. > 2) Event handling in general. For example, a checkbox menu item doesn't > "know" its parent, so when it's clicked, it can't run commands on its > parent applet without bubbling an event up to its parent jmol object. I > will continue to work on this, but event handling in JS is not one of my > specialties. I'll look into custom events mediated by jQuery, but in the > meantime, if there are any JS event experts out there, help would be > appreciated! :-) > Actually, it does. What you are missing is that when a checkbox is created, the following command sequence is run: /** * @j2sNative * * if (isRadio) { *item = new Jmol.Menu.RadioButtonMenuItem(entry); *item.setArmed(state); * } else { *item = new Jmol.Menu.CheckBoxMenuItem(entry); *item.setState(state); * } * item.setSelected(state); * item.addItemListener(this); * */ So that "addItemListener" is giving the checkbox a reference to the instance of org.jmol.awt2d.JSPopup that created it. Store that as jmolPopup in the item. Then: .jmolPopup.checkBoxStateChanged(); Similarly, all normal menu items have: /** * @j2sNative * * item = new Jmol.Menu.MenuItem(entry); * item.addActionListener(this); * */ (notice "Action" here, not "Item") This is going to respond to clicks: .jmolPopup.checkMenuClick(, .getActionCommand()); where getActionCommand() returns "background yellow" should take care of it. Finally, there are a few items that are special and start with "Focus". These also get a mouse listener so that we can track when they are entered and exited: /** * @j2sNative *if (id != null && id.startsWith("Focus")) { * item.addMouseListener(this); * id = menu.getName() + "." + id; *} *item.setName(id == null ? menu.getName() + "." : id); */ Then that needs to be set up so that we can run: item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), true); item.jmolPopup.checkMenuFocus(item.getName(), item.getActionCommand(), false); And we should be done! By the way, your comment there that it should be OK to use a null instead of removing an item is not right. This could happen extensively, and we need to actually remove that array element. Bob -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
Michael, I've uploaded files to chemapps.stolaf.edu. The Java side is all done -- when you go to the page using &debugcode: http://chemapps.stolaf.edu/jmol/jsmol/test2.htm?USE=HTML5&debugcode then it will use the modifications I have put in place, and right-clicking on the applet or clicking the logo will do an alert from the method in Jmol that is creating the menu. I suggest figuring out how to handle it with just JavaScript objects (probably arrays, I guess) and then only after you have that in place start working with jQuery. Bob On Wed, Dec 19, 2012 at 9:10 AM, Michael Evans wrote: > Thanks, Bob. I got the sense objects would be the way to go. Working on > this this morning. Stay tuned! > > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > On Wed, Dec 19, 2012 at 8:56 AM, Robert Hanson wrote: > >> OK, Michael, here's what we actually need from the JavaScript side. From >> org.jmol.awt2d.JSPopup: >> >> //TODO: jQuery menu actions, entry, and exit need to come back here >> // to execute checkMenuClick, checkMenuFocus, and >> checkBoxStateChanged >> >> // (on mouse up) checkMenuClick(e.getSource(), >> e.getSource().getActionCommand()); >> // (on entry) checkMenuFocus(item.getName(), >> item.getActionCommand(), true); >> // (on exit) checkMenuFocus(item.getName(), >> item.getActionCommand(), false); >> // (on checkbox click) checkBoxStateChanged(e.getSource()); >> >> //TODO: JavaScript objects: >> // new Jmol.Menu.PopupMenu(name) >> // new Jmol.Menu.SubMenu(entry) >> // new Jmol.Menu.MenuItem(entry) >> // new Jmol.Menu.ButtonGroup() >> // new Jmol.Menu.CheckBoxMenuItem(entry) >> // new Jmol.Menu.RadioButtonMenuItem(entry) >> // >> //TODO: Jmol given in j2sNative blocks, for example: setText, >> setActionCommand >> >> see >> http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java?content-type=text%2Fplain >> >> I'll help. The interface I gave you before is actually for Java; what we >> need to implement in JavaScript is a bit different. Look in that file for >> @j2sNative blocks, and you will at least be able to construct a list of >> needed functions. Many of these methods will be called from >> >> >> http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/popup/GenericPopup.java?content-type=text%2Fplain >> >> Bob >> >> >> >> On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: >> >>> Jmol community, >>> Here's a simple example of a context menu in JSmol: >>> >>> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >>> >>> Dig into the document ready function and jmolPopupMenu.js for details. >>> The whole kit and kaboodle (including jQueryUI menu, which I used to handle >>> the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its >>> associated functions: >>> >>> initializeMenu >>> menuAddItem(menu, item) >>> menuRemoveItem(menu, itemId) >>> menuAddSubmenu(menu, submenu) >>> menuAddSeparator(menu) >>> menuEnableItem(menu, itemId, boolEnable) >>> >>> Should the "items" sent to menuAddItem, etc. just be HTML, or something >>> more abstract like Javascript objects? There are no jQueryUI objects for >>> things like radio groups and checkboxes...these would have to be handled by >>> us somewhere on the path from abstract menu object to final rendered menu. >>> Would be interested to hear your thoughts on the best way to implement >>> addItem. >>> >>> Cheers, Mike >>> >>> --- >>> Michael Evans >>> Organic Chemistry Graduate Student, Moore Group >>> University of Illinois, Urbana-Champaign >>> >>> >>> >>> -- >>> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >>> Remotely access PCs and mobile devices and provide instant support >>> Improve your efficiency, and focus on delivering more value-add services >>> Discover what IT Professionals Know. Rescue delivers >>> http://p.sf.net/sfu/logmein_12329d2d >>> ___ >>> Jmol-users mailing list >>> Jmol-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/jmol-users >>> >>> >> >> >> -- >> Robert M. Hanson >> Larson-Anderson Professor of Chemistry >> Chair, Chemistry Department >> St. Olaf College >> Northfield, MN >> http://www.stolaf.edu/people/hansonr >> >> >> If nature does not answer first what we want, >> it is better to take what answer we get. >> >> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 >> >> >> >> -- >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> Remotely access PCs and mobile devices and provide instant support >> Improve your efficiency, and focus on delivering more value-add services >> Discover what IT Professionals Know. R
Re: [Jmol-users] Jmol | Context Menu for JSmol
Bob et al., Progress has been made on a popup menu for JSmol. I've implemented PopupMenu, MenuItem, CheckboxMenuItem, and RadioButtonMenuItem, among other things. Check it out: http://www.metallacycle.com/play/netmol/tests/popupMenu/jmolPopupMenu.js The demo is still functional as well: http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html Two things I'm struggling with: 1) What's the difference between a ButtonGroup and a set of RadioButtonMenuItems? 2) Event handling in general. For example, a checkbox menu item doesn't "know" its parent, so when it's clicked, it can't run commands on its parent applet without bubbling an event up to its parent jmol object. I will continue to work on this, but event handling in JS is not one of my specialties. I'll look into custom events mediated by jQuery, but in the meantime, if there are any JS event experts out there, help would be appreciated! :-) Is this what you had in mind, Bob? Cheers, Mike --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign On Wed, Dec 19, 2012 at 9:10 AM, Michael Evans wrote: > Thanks, Bob. I got the sense objects would be the way to go. Working on > this this morning. Stay tuned! > > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > On Wed, Dec 19, 2012 at 8:56 AM, Robert Hanson wrote: > >> OK, Michael, here's what we actually need from the JavaScript side. From >> org.jmol.awt2d.JSPopup: >> >> //TODO: jQuery menu actions, entry, and exit need to come back here >> // to execute checkMenuClick, checkMenuFocus, and >> checkBoxStateChanged >> >> // (on mouse up) checkMenuClick(e.getSource(), >> e.getSource().getActionCommand()); >> // (on entry) checkMenuFocus(item.getName(), >> item.getActionCommand(), true); >> // (on exit) checkMenuFocus(item.getName(), >> item.getActionCommand(), false); >> // (on checkbox click) checkBoxStateChanged(e.getSource()); >> >> //TODO: JavaScript objects: >> // new Jmol.Menu.PopupMenu(name) >> // new Jmol.Menu.SubMenu(entry) >> // new Jmol.Menu.MenuItem(entry) >> // new Jmol.Menu.ButtonGroup() >> // new Jmol.Menu.CheckBoxMenuItem(entry) >> // new Jmol.Menu.RadioButtonMenuItem(entry) >> // >> //TODO: Jmol given in j2sNative blocks, for example: setText, >> setActionCommand >> >> see >> http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java?content-type=text%2Fplain >> >> I'll help. The interface I gave you before is actually for Java; what we >> need to implement in JavaScript is a bit different. Look in that file for >> @j2sNative blocks, and you will at least be able to construct a list of >> needed functions. Many of these methods will be called from >> >> >> http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/popup/GenericPopup.java?content-type=text%2Fplain >> >> Bob >> >> >> >> On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: >> >>> Jmol community, >>> Here's a simple example of a context menu in JSmol: >>> >>> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >>> >>> Dig into the document ready function and jmolPopupMenu.js for details. >>> The whole kit and kaboodle (including jQueryUI menu, which I used to handle >>> the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its >>> associated functions: >>> >>> initializeMenu >>> menuAddItem(menu, item) >>> menuRemoveItem(menu, itemId) >>> menuAddSubmenu(menu, submenu) >>> menuAddSeparator(menu) >>> menuEnableItem(menu, itemId, boolEnable) >>> >>> Should the "items" sent to menuAddItem, etc. just be HTML, or something >>> more abstract like Javascript objects? There are no jQueryUI objects for >>> things like radio groups and checkboxes...these would have to be handled by >>> us somewhere on the path from abstract menu object to final rendered menu. >>> Would be interested to hear your thoughts on the best way to implement >>> addItem. >>> >>> Cheers, Mike >>> >>> --- >>> Michael Evans >>> Organic Chemistry Graduate Student, Moore Group >>> University of Illinois, Urbana-Champaign >>> >>> >>> >>> -- >>> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >>> Remotely access PCs and mobile devices and provide instant support >>> Improve your efficiency, and focus on delivering more value-add services >>> Discover what IT Professionals Know. Rescue delivers >>> http://p.sf.net/sfu/logmein_12329d2d >>> ___ >>> Jmol-users mailing list >>> Jmol-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/jmol-users >>> >>> >> >> >> -- >> Robert M. Hanson >> Larson-Anderson Professor of Chemistry >> Chair, Chemistry Department >> St. Olaf College >> Northfield, MN >> http://www.stolaf
Re: [Jmol-users] Jmol | Context Menu for JSmol
Thanks, Bob. I got the sense objects would be the way to go. Working on this this morning. Stay tuned! --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign On Wed, Dec 19, 2012 at 8:56 AM, Robert Hanson wrote: > OK, Michael, here's what we actually need from the JavaScript side. From > org.jmol.awt2d.JSPopup: > > //TODO: jQuery menu actions, entry, and exit need to come back here > // to execute checkMenuClick, checkMenuFocus, and > checkBoxStateChanged > > // (on mouse up) checkMenuClick(e.getSource(), > e.getSource().getActionCommand()); > // (on entry) checkMenuFocus(item.getName(), > item.getActionCommand(), true); > // (on exit) checkMenuFocus(item.getName(), > item.getActionCommand(), false); > // (on checkbox click) checkBoxStateChanged(e.getSource()); > > //TODO: JavaScript objects: > // new Jmol.Menu.PopupMenu(name) > // new Jmol.Menu.SubMenu(entry) > // new Jmol.Menu.MenuItem(entry) > // new Jmol.Menu.ButtonGroup() > // new Jmol.Menu.CheckBoxMenuItem(entry) > // new Jmol.Menu.RadioButtonMenuItem(entry) > // > //TODO: Jmol given in j2sNative blocks, for example: setText, > setActionCommand > > see > http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java?content-type=text%2Fplain > > I'll help. The interface I gave you before is actually for Java; what we > need to implement in JavaScript is a bit different. Look in that file for > @j2sNative blocks, and you will at least be able to construct a list of > needed functions. Many of these methods will be called from > > > http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/popup/GenericPopup.java?content-type=text%2Fplain > > Bob > > > > On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > >> Jmol community, >> Here's a simple example of a context menu in JSmol: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Dig into the document ready function and jmolPopupMenu.js for details. >> The whole kit and kaboodle (including jQueryUI menu, which I used to handle >> the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its >> associated functions: >> >> initializeMenu >> menuAddItem(menu, item) >> menuRemoveItem(menu, itemId) >> menuAddSubmenu(menu, submenu) >> menuAddSeparator(menu) >> menuEnableItem(menu, itemId, boolEnable) >> >> Should the "items" sent to menuAddItem, etc. just be HTML, or something >> more abstract like Javascript objects? There are no jQueryUI objects for >> things like radio groups and checkboxes...these would have to be handled by >> us somewhere on the path from abstract menu object to final rendered menu. >> Would be interested to hear your thoughts on the best way to implement >> addItem. >> >> Cheers, Mike >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois, Urbana-Champaign >> >> >> >> -- >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> Remotely access PCs and mobile devices and provide instant support >> Improve your efficiency, and focus on delivering more value-add services >> Discover what IT Professionals Know. Rescue delivers >> http://p.sf.net/sfu/logmein_12329d2d >> ___ >> Jmol-users mailing list >> Jmol-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jmol-users >> >> > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge
Re: [Jmol-users] Jmol | Context Menu for JSmol
OK, Michael, here's what we actually need from the JavaScript side. From org.jmol.awt2d.JSPopup: //TODO: jQuery menu actions, entry, and exit need to come back here // to execute checkMenuClick, checkMenuFocus, and checkBoxStateChanged // (on mouse up) checkMenuClick(e.getSource(), e.getSource().getActionCommand()); // (on entry) checkMenuFocus(item.getName(), item.getActionCommand(), true); // (on exit) checkMenuFocus(item.getName(), item.getActionCommand(), false); // (on checkbox click) checkBoxStateChanged(e.getSource()); //TODO: JavaScript objects: // new Jmol.Menu.PopupMenu(name) // new Jmol.Menu.SubMenu(entry) // new Jmol.Menu.MenuItem(entry) // new Jmol.Menu.ButtonGroup() // new Jmol.Menu.CheckBoxMenuItem(entry) // new Jmol.Menu.RadioButtonMenuItem(entry) // //TODO: Jmol given in j2sNative blocks, for example: setText, setActionCommand see http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/awtjs2d/JSPopup.java?content-type=text%2Fplain I'll help. The interface I gave you before is actually for Java; what we need to implement in JavaScript is a bit different. Look in that file for @j2sNative blocks, and you will at least be able to construct a list of needed functions. Many of these methods will be called from http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/src/org/jmol/popup/GenericPopup.java?content-type=text%2Fplain Bob On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > Jmol community, > Here's a simple example of a context menu in JSmol: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Dig into the document ready function and jmolPopupMenu.js for details. The > whole kit and kaboodle (including jQueryUI menu, which I used to handle the > visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its > associated functions: > > initializeMenu > menuAddItem(menu, item) > menuRemoveItem(menu, itemId) > menuAddSubmenu(menu, submenu) > menuAddSeparator(menu) > menuEnableItem(menu, itemId, boolEnable) > > Should the "items" sent to menuAddItem, etc. just be HTML, or something > more abstract like Javascript objects? There are no jQueryUI objects for > things like radio groups and checkboxes...these would have to be handled by > us somewhere on the path from abstract menu object to final rendered menu. > Would be interested to hear your thoughts on the best way to implement > addItem. > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
I think you need to look into how jQueryUI implements these. They are some sort of object, I'm sure. AddItem will insert a I'm guessing, in a list of divs. But you can keep track of them with arrays yourself. I think it makes sense to build some sort of structure that is basically an array of arrays to hold the menu regardless of what jQuery does. Then, in the future, if we wanted to implement some other scheme, we could. On Tue, Dec 18, 2012 at 2:30 PM, Robert Hanson wrote: > super! > > > > On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > >> Jmol community, >> Here's a simple example of a context menu in JSmol: >> >> http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html >> >> Dig into the document ready function and jmolPopupMenu.js for details. >> The whole kit and kaboodle (including jQueryUI menu, which I used to handle >> the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its >> associated functions: >> >> initializeMenu >> menuAddItem(menu, item) >> menuRemoveItem(menu, itemId) >> menuAddSubmenu(menu, submenu) >> menuAddSeparator(menu) >> menuEnableItem(menu, itemId, boolEnable) >> >> Should the "items" sent to menuAddItem, etc. just be HTML, or something >> more abstract like Javascript objects? >> > > These should definitely be objects. I would say something that mirrors > those in the Java system: > > import java.awt.Component; > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; > import java.awt.event.ItemEvent; > import java.awt.event.ItemListener; > import java.awt.event.MouseEvent; > import java.awt.event.MouseListener; > > import javax.swing.AbstractButton; > import javax.swing.ButtonGroup; > import javax.swing.ImageIcon; > import javax.swing.JCheckBoxMenuItem; > import javax.swing.JComponent; > import javax.swing.JMenu; > import javax.swing.JMenuItem; > import javax.swing.JPopupMenu; > import javax.swing.JRadioButtonMenuItem; > > Not saying we have to use all of those, but they are there for a reason, > and every one is accessed in one way or another to set the menus. > > > >> There are no jQueryUI objects for things like radio groups and >> checkboxes...these would have to be handled by us somewhere on the path >> from abstract menu object to final rendered menu. Would be interested to >> hear your thoughts on the best way to implement addItem. >> >> Cheers, Mike >> >> --- >> Michael Evans >> Organic Chemistry Graduate Student, Moore Group >> University of Illinois, Urbana-Champaign >> >> >> >> -- >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> Remotely access PCs and mobile devices and provide instant support >> Improve your efficiency, and focus on delivering more value-add services >> Discover what IT Professionals Know. Rescue delivers >> http://p.sf.net/sfu/logmein_12329d2d >> ___ >> Jmol-users mailing list >> Jmol-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jmol-users >> >> > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > Chair, Chemistry Department > St. Olaf College > Northfield, MN > http://www.stolaf.edu/people/hansonr > > > If nature does not answer first what we want, > it is better to take what answer we get. > > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 > > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Jmol | Context Menu for JSmol
super! On Tue, Dec 18, 2012 at 11:57 AM, Michael Evans wrote: > Jmol community, > Here's a simple example of a context menu in JSmol: > > http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html > > Dig into the document ready function and jmolPopupMenu.js for details. The > whole kit and kaboodle (including jQueryUI menu, which I used to handle the > visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its > associated functions: > > initializeMenu > menuAddItem(menu, item) > menuRemoveItem(menu, itemId) > menuAddSubmenu(menu, submenu) > menuAddSeparator(menu) > menuEnableItem(menu, itemId, boolEnable) > > Should the "items" sent to menuAddItem, etc. just be HTML, or something > more abstract like Javascript objects? > These should definitely be objects. I would say something that mirrors those in the Java system: import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JRadioButtonMenuItem; Not saying we have to use all of those, but they are there for a reason, and every one is accessed in one way or another to set the menus. > There are no jQueryUI objects for things like radio groups and > checkboxes...these would have to be handled by us somewhere on the path > from abstract menu object to final rendered menu. Would be interested to > hear your thoughts on the best way to implement addItem. > > Cheers, Mike > > --- > Michael Evans > Organic Chemistry Graduate Student, Moore Group > University of Illinois, Urbana-Champaign > > > > -- > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
[Jmol-users] Jmol | Context Menu for JSmol
Jmol community, Here's a simple example of a context menu in JSmol: http://www.metallacycle.com/play/netmol/tests/popupMenu/popupMenu.html Dig into the document ready function and jmolPopupMenu.js for details. The whole kit and kaboodle (including jQueryUI menu, which I used to handle the visuals) is 165 KB at the moment. The JS file adds Jmol.Menu with its associated functions: initializeMenu menuAddItem(menu, item) menuRemoveItem(menu, itemId) menuAddSubmenu(menu, submenu) menuAddSeparator(menu) menuEnableItem(menu, itemId, boolEnable) Should the "items" sent to menuAddItem, etc. just be HTML, or something more abstract like Javascript objects? There are no jQueryUI objects for things like radio groups and checkboxes...these would have to be handled by us somewhere on the path from abstract menu object to final rendered menu. Would be interested to hear your thoughts on the best way to implement addItem. Cheers, Mike --- Michael Evans Organic Chemistry Graduate Student, Moore Group University of Illinois, Urbana-Champaign -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users