Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Robert Hanson
On Wed, Mar 29, 2017 at 2:14 PM, David Hibbitts  wrote:

> Thanks for the input everyone. The keyboard input will control jmol/jsmol
> but also do other things, but I do like using arrow keys to rotate the
> structure, for example. Other features can be added later to allow jmol to
> more easily *modify* rather than merely view structures. It's hard to
> imagine these features without a fuller keyboard interface (features
> similar to the structure-editing capabilities of avogadro or materials
> studio).
>

set modelkitmode

allows substantial editing, but perhaps not up to those programs in terms
of interface. Still, you can do a lot. Have you experimented with it?



>
> The javascript version already works perfectly, as keyed events are
> captured by the website (even if jsmol previously has focus) and I'm just
> using javascript to do whatever I want to do (including interacting with
> jsmol via JmolScript calls).
>
> For the java version, the best I've been able to do is: use a function
> which restores focus to the website (so they keyboard commands aren't
> trapped by jmol) whenever 1) a script is executed by jmol using
> ScriptCallback or 2) the users mouse leaves the jmol div (using a
> standard mouseout event in the DOM). This means the user doesn't have to
> "click" off of jmol to restore focus and re-enable the keyboard
> interactions. It doesn't help if the user, for example, uses the mouse to
> rotate the structure and leaves the mouse on jmol the entire time. In
> that instance, jmolnever loses focus and so the keyboard events aren't
> passed to the website.
>

That's clever.


>
> I could use the callbacks more aggressively, for example by using
> pickcallback and hovercallback -- but those are uncommon cases -- what I
> really need is something more encompassing like a "MouseUpCallback" so that
> any time the clicks on jmol I can redirect focus back to the website.
> Unfortunately, that callback doesn't exist in the jmol scripting
> environment.
>
>

> It's hard to know how much any of us should invest in these java-specific
> issues given the aggressive nature of browsers toward javascript -- but my
> website really serves my research group, not the general public, and there
> I can certainly get the users to install Waterfox+JAVA.
>
>
Ah, that is very good to hear. I have been trying to promote the idea that
browser-based Jmol can be very much for local use such as that.

Bob
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread David Hibbitts
Thanks for the input everyone. The keyboard input will control jmol/jsmol
but also do other things, but I do like using arrow keys to rotate the
structure, for example. Other features can be added later to allow jmol to
more easily *modify* rather than merely view structures. It's hard to
imagine these features without a fuller keyboard interface (features
similar to the structure-editing capabilities of avogadro or materials
studio).

The javascript version already works perfectly, as keyed events are
captured by the website (even if jsmol previously has focus) and I'm just
using javascript to do whatever I want to do (including interacting with
jsmol via JmolScript calls).

For the java version, the best I've been able to do is: use a function
which restores focus to the website (so they keyboard commands aren't
trapped by jmol) whenever 1) a script is executed by jmol using
ScriptCallback or 2) the users mouse leaves the jmol div (using a standard
mouseout event in the DOM). This means the user doesn't have to "click" off
of jmol to restore focus and re-enable the keyboard interactions. It
doesn't help if the user, for example, uses the mouse to rotate the
structure and leaves the mouse on jmol the entire time. In that instance,
jmolnever loses focus and so the keyboard events aren't passed to the
website.

I could use the callbacks more aggressively, for example by using
pickcallback and hovercallback -- but those are uncommon cases -- what I
really need is something more encompassing like a "MouseUpCallback" so that
any time the clicks on jmol I can redirect focus back to the website.
Unfortunately, that callback doesn't exist in the jmol scripting
environment.

It's hard to know how much any of us should invest in these java-specific
issues given the aggressive nature of browsers toward javascript -- but my
website really serves my research group, not the general public, and there
I can certainly get the users to install Waterfox+JAVA.

Thanks

On Wed, Mar 29, 2017 at 2:43 PM, Robert Hanson  wrote:

> (sorry, I missed that nuance)
> ​
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Robert Hanson
(sorry, I missed that nuance)
​
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Robert Hanson
Only the JavaScript version.

On Wed, Mar 29, 2017 at 11:32 AM, Rolf Huehne 
wrote:

> Am 29.03.17 um 18:21 schrieb Robert Hanson:
> > David,
> >
> > OK, so the beauty of this system is that you can implement any sort of
> > additional functionality you want using readily available methods that
> > have nothing to do with Jmol or JSmol. It's one of the bonuses of
> > working in JavaScript and jQuery.
> >
> > So, for example, if you want to implement a key listener that
> > implements  + and - to actuate zooming, you can do it this way:
> >
> > c = $("#jmolApplet0_canvas2d")
> > c.attr("tabindex", 1)
> > c.mouseover(function(){c.focus()})
> > c.keypress(function(e){
> >   if (e.key == "+")Jmol.script(jmolApplet0, "zoom *1.2")
> >   else  if (e.key == "-")Jmol.script(jmolApplet0, "zoom /1.2")
> > })
> >
> > Notice that to accept key events, we must (a) provide a tabindex to the
> > canvas and (b) make sure the canvas has focus when we are looking for
> > key events.
> >
> > I would only say that hidden specialized features like this, though
> > potentially useful, are not necessarily recommended.
> > ​
> It looks like the example would only work for the Javascript version. Or
> could it also work for the Java version (with some adjustment)?
>
> Regards,
> Rolf
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> 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
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
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Rolf Huehne
Am 29.03.17 um 18:21 schrieb Robert Hanson:
> David,
>
> OK, so the beauty of this system is that you can implement any sort of
> additional functionality you want using readily available methods that
> have nothing to do with Jmol or JSmol. It's one of the bonuses of
> working in JavaScript and jQuery.
>
> So, for example, if you want to implement a key listener that
> implements  + and - to actuate zooming, you can do it this way:
>
> c = $("#jmolApplet0_canvas2d")
> c.attr("tabindex", 1)
> c.mouseover(function(){c.focus()})
> c.keypress(function(e){
>   if (e.key == "+")Jmol.script(jmolApplet0, "zoom *1.2")
>   else  if (e.key == "-")Jmol.script(jmolApplet0, "zoom /1.2")
> })
>
> Notice that to accept key events, we must (a) provide a tabindex to the
> canvas and (b) make sure the canvas has focus when we are looking for
> key events.
>
> I would only say that hidden specialized features like this, though
> potentially useful, are not necessarily recommended.
> ​
It looks like the example would only work for the Javascript version. Or 
could it also work for the Java version (with some adjustment)?

Regards,
Rolf

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Robert Hanson
David,

OK, so the beauty of this system is that you can implement any sort of
additional functionality you want using readily available methods that have
nothing to do with Jmol or JSmol. It's one of the bonuses of working in
JavaScript and jQuery.

So, for example, if you want to implement a key listener that implements  +
and - to actuate zooming, you can do it this way:

c = $("#jmolApplet0_canvas2d")
c.attr("tabindex", 1)
c.mouseover(function(){c.focus()})
c.keypress(function(e){
  if (e.key == "+")Jmol.script(jmolApplet0, "zoom *1.2")
  else  if (e.key == "-")Jmol.script(jmolApplet0, "zoom /1.2")
})

Notice that to accept key events, we must (a) provide a tabindex to the
canvas and (b) make sure the canvas has focus when we are looking for key
events.

I would only say that hidden specialized features like this, though
potentially useful, are not necessarily recommended.
​

Bob
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Rolf Huehne
Am 29.03.17 um 17:37 schrieb Angel Herráez:
> Have you checked Jmol's "navigation mode" ?
> As far as I remember, it  used the keyboard.
> But maybe it is only applicable to the Jmol application.
>
> http://chemapps.stolaf.edu/jmol/docs/#navigate
> http://chemapps.stolaf.edu/jmol/docs/#setnavigation
>
I don't find the navigation mode very suitable as a standard method for 
exploring a structure. In some cases it might be useful but my own 
experiences were rather unsatisfying.

Regards,
Rolf


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Angel Herráez
Have you checked Jmol's "navigation mode" ?
As far as I remember, it  used the keyboard. 
But maybe it is only applicable to the Jmol application.

http://chemapps.stolaf.edu/jmol/docs/#navigate
http://chemapps.stolaf.edu/jmol/docs/#setnavigation


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-29 Thread Rolf Huehne
Am 28.03.17 um 22:26 schrieb David Hibbitts:
> So the "allowkeystrokes" feature simply lets you send commands to the
> console?
>
> No, that's not useful for me -- I'm sure someone has tried to implement
> navigation-by-keyboard on their jmol-including website before.
>
It would be great if this would be possible. Especially because mouse 
control of Jmol-Java on MacOS became problematic in browsers.

For example could '+/-' for zoom in/out be very handy. The zoom "slider" 
near the right applet border is quite inconvenient. And the only mouse 
binding that does work is on the left mouse button without any 
modifiers. So keyboard commands for translation and Z-rotation could 
also be very helpful.

Regards,
Rolf

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-28 Thread David Hibbitts
So the "allowkeystrokes" feature simply lets you send commands to the
console?

No, that's not useful for me -- I'm sure someone has tried to implement
navigation-by-keyboard on their jmol-including website before.

On Tue, Mar 28, 2017 at 12:20 PM, Rolf Huehne 
wrote:

> Am 28.03.17 um 17:55 schrieb David Hibbitts:
> > I would like to add keyboard shortcuts to my web application. I can do
> > this with javascript without any issue using something like Mousetrap
> > and I can interact with jsmol via jmolScript calls.
> >
> > The issue comes when using the Java version (which I still use via
> > Waterfox because I'm stubborn and it is faster).
> >
> > The jmol applet in the Java version seems to trap all keystrokes and
> > pass nothing to the underlying browser while the jmol applet has focus
> > -- is there any way to have the jmol applet pass all unbound keystrokes
> > to the browser?
> >
> > Alternatively, is there a way to have jmol call custom functions
> > whenever a key is pressed? If so I can just define the keyboard
> > shortcuts in both Mousetrap and jmol.
> >
> > I attempted to play with set allowKeystrokes and set showKeyStrokes but
> > I didn't really get anywhere. allowKeystrokes just caused my applet to
> > freeze and nothing but a refresh would bring it back. showKeystrokes
> > didn't really work on my screen, although it's possible that the
> > bottom-left corner of the applet is offscreen, set echo top left didn't
> > change anything. Again my testing of allowKeystrokes and showKeystrokes
> > was in the Java version of jmol using Waterfox.
> >
> David, on MacOS 10.11.6 with Waterfox 52.0 the command combination 'set
> allowkeystrokes; set showkeystrokes' does work for me in Jmol 14.9.1.
>
> I could change for example the background color by typing "background
> yellow" and then press RETURN. And the text also appeared at the bottom
> left of the applet window. The whole process was terminated and the
> typed text ignored if I moved the mouse pointer.
>
> But I think this is not quite what you would like to have, isn't it?
>
> Regards,
> Rolf
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Jmol Keyboard Interaction

2017-03-28 Thread Rolf Huehne
Am 28.03.17 um 17:55 schrieb David Hibbitts:
> I would like to add keyboard shortcuts to my web application. I can do
> this with javascript without any issue using something like Mousetrap
> and I can interact with jsmol via jmolScript calls.
>
> The issue comes when using the Java version (which I still use via
> Waterfox because I'm stubborn and it is faster).
>
> The jmol applet in the Java version seems to trap all keystrokes and
> pass nothing to the underlying browser while the jmol applet has focus
> -- is there any way to have the jmol applet pass all unbound keystrokes
> to the browser?
>
> Alternatively, is there a way to have jmol call custom functions
> whenever a key is pressed? If so I can just define the keyboard
> shortcuts in both Mousetrap and jmol.
>
> I attempted to play with set allowKeystrokes and set showKeyStrokes but
> I didn't really get anywhere. allowKeystrokes just caused my applet to
> freeze and nothing but a refresh would bring it back. showKeystrokes
> didn't really work on my screen, although it's possible that the
> bottom-left corner of the applet is offscreen, set echo top left didn't
> change anything. Again my testing of allowKeystrokes and showKeystrokes
> was in the Java version of jmol using Waterfox.
>
David, on MacOS 10.11.6 with Waterfox 52.0 the command combination 'set 
allowkeystrokes; set showkeystrokes' does work for me in Jmol 14.9.1.

I could change for example the background color by typing "background 
yellow" and then press RETURN. And the text also appeared at the bottom 
left of the applet window. The whole process was terminated and the 
typed text ignored if I moved the mouse pointer.

But I think this is not quite what you would like to have, isn't it?

Regards,
Rolf

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users