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 <[email protected]> wrote:

> Wow, this is great! Almost there, I think.
> 
> 
> On Wed, Dec 19, 2012 at 12:48 PM, Michael Evans <[email protected]> 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:
> 
>  xxxx.jmolPopup.checkBoxStateChanged(xxxx);   
> 
> 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:
> 
> xxxx.jmolPopup.checkMenuClick(xxxx, xxxx.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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to