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