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

> OK. I'm working on the patch now.
>
>
> On Sat, Dec 22, 2012 at 11:22 AM, Michael Evans <[email protected]>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 <[email protected]>wrote:
>>
>>>
>>>
>>>
>>> On Sat, Dec 22, 2012 at 12:56 AM, Michael Evans <[email protected]>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 <img> 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 <[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
>>>>
>>>>
>>>
>>>
>>> --
>>> 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
>>
>>
>
>
> --
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to