g.getevent() ambiguous documentation in golly-2.7-gtk

Has something gone haywire? Let us know about it!
Post Reply
User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 15th, 2016, 11:02 pm

I was watching the user-input keystrokes like this:

Code: Select all

import golly as g
while True:
    event = g.getevent()
    if event:
        g.show(event)
(Anyone who wants to check this out: copy this to the clipboard and in Golly and go to: File>Run clipboard)

I saw two ambiguous details from the documentation:

1) Cross-platform scripting
One-line summary: Got 'key c altctrlshift' while expecting 'key c altcmdshift'.

I'm trying to assign a trigger action to each key (i.e. Ctrl+C -> Copy) and I was trying to make it cross-platform. The documentation of getevent() says that you could make it cross-platform by using 'cmd' and 'alt', which replaces 'ctrl' and 'option', respectively. But running the script above gives something like 'key c altctrlshift' instead of 'key c altcmdshift'. Does the cross-platform thing only apply to g.doevent() rather than g.getevent()?

2) The capital letters
One-line summary: Got 'key M none' instead of 'key m shift'.

This is not necessarily different from the docs but I think this is worth a mention. (Or is it different in different platforms?)

I'm on 32bit Linux and use Lubuntu. Thanks in advance.
Best wishes to you, Scorbie

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 16th, 2016, 6:23 am

One more related thing: Golly ignores Ctrl+O and Ctrl+S keys in g.getevent().
Best wishes to you, Scorbie

User avatar
Andrew
Moderator
Posts: 764
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Andrew » January 16th, 2016, 8:27 pm

Scorbie wrote:Got 'key c altctrlshift' while expecting 'key c altcmdshift'.
getevent() will only return the "cmd" modifier on a Mac (where there is both a command key and a control key). I'll fix the docs to make that a bit clearer.
Does the cross-platform thing only apply to g.doevent() rather than g.getevent()?
Correct. For example, to quit Golly from a script it's best to do this:

Code: Select all

import golly
golly.doevent("key q cmd")
That will work on all platforms, whereas "key q ctrl" will only work on Windows and Linux.
Got 'key M none' instead of 'key m shift'.
That's somewhat unfortunate. The behaviour on Linux must have changed from wxWidgets 2.8 to 3.0. It was quite hard to get the event handling code to be consistent on all platforms (some of Golly's ugliest code can be seen in the OnKeyDown and OnChar handlers in wxview.cpp). If the above difference is only limited to the handling of letters (ie. A to Z) then it should be quite easy to test for both cases.

I'd be interested to hear what you get when typing key combos like shift-1 or shift-/. On my Mac I get "key ! none" and "key ? none" respectively. Hopefully you get the same on Linux (assuming a US keyboard layout).

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 16th, 2016, 8:39 pm

@Andrew Thanks for the reply! I get the same thing.
Best wishes to you, Scorbie

User avatar
Andrew
Moderator
Posts: 764
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Andrew » January 16th, 2016, 8:45 pm

Scorbie wrote:One more related thing: Golly ignores Ctrl+O and Ctrl+S keys in g.getevent().
That is very surprising! On my Mac I see the expected strings if I type cmd-O or cmd-S (ditto for ctrl-O or ctrl-S) so I don't really understand why Golly doesn't see those key combos on Linux. Unless they are system shortcuts? Note that on a Mac the getevent() command will never see cmd-H because that's a system shortcut (to hide the current app).

When your test script is running, check your File menu. Do you see Ctrl+O and Ctrl+S displayed next to the Open and Save menu items? You should NOT see them because Golly temporarily removes all menu item shortcuts while a script is running (I did this mainly for Windows, where it prevented getevent() seeing the key combo even if the menu item's shortcut was disabled). Perhaps that removal code has stopped working on Linux?

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 16th, 2016, 8:52 pm

Andrew wrote: When your test script is running, check your File menu. Do you see Ctrl+O and Ctrl+S displayed next to the Open and Save menu items? You should NOT see them because Golly temporarily removes all menu item shortcuts while a script is running (I did this mainly for Windows, where it prevented getevent() seeing the key combo even if the menu item's shortcut was disabled). Perhaps that removal code has stopped working on Linux?
Actually, they're disabled (grayed out) all right...
EDIT: I tried to take a snapshot but it refuses to take a snapshot with the File menu open... Hope I described it well enough.
EDIT3: (Sorry about the edits...) Golly works well with Ctrl+O and Ctrl+S without the script running, which seems to be conclusive evidence that the system shortcut is not a problem.

IF the system shortcuts were a problem, I think there's nothing you have to do about it, as there are a lot of distros/desktop managers/window managers with different shortcuts each.
Best wishes to you, Scorbie

User avatar
Andrew
Moderator
Posts: 764
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Andrew » January 16th, 2016, 9:18 pm

Scorbie wrote:Actually, they're disabled (grayed out)...
They should be completely removed. Well that explains why getevent() isn't seeing them. I'll have to figure out why the removal code isn't working on Linux (probably another bl**dy wxWidgets bug I'll have to work around). Could be a while -- my Linux VM is on that dead hard drive...

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 16th, 2016, 10:15 pm

Andrew wrote:
Scorbie wrote:Actually, they're disabled (grayed out)...
They should be completely removed. Well that explains why getevent() isn't seeing them. I'll have to figure out why the removal code isn't working on Linux (probably another bl**dy wxWidgets bug I'll have to work around). Could be a while -- my Linux VM is on that dead hard drive...
Ahh, so it's the menu item shortcuts... Okay... I think I should have a workaround with my script anyway for compatibility issues with Golly 2.7... So take your time... R.I.P Linux VM...
Best wishes to you, Scorbie

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 17th, 2016, 1:35 am

Hmm... Sorry for the nuisance, but I got another bug...
1. Run a script that takes some time to run (Like the one I posted above)
2. Manipulate the Paste Mode/ Paste Location on the Edit tab. (Or put a golly.doevent('key m shift') line somewhere on your script.)
3. Quit the script and you'll see some menus in all tabs (by tabs I mean View, Edit, ... tabs.) are disabled (grayed off)

I was wondering if the user is able to change the Paste mode and Paste Location. There isn't an API to retrieve and use the paste mode and paste location, is there?
Best wishes to you, Scorbie

User avatar
Andrew
Moderator
Posts: 764
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Andrew » January 17th, 2016, 8:25 am

Scorbie wrote:3. Quit the script and you'll see some menus in all tabs (by tabs I mean View, Edit, ... tabs.) are disabled (grayed off)
I can't reproduce this problem on my Mac. Can you give a specific example of a menu item that has become disabled that shouldn't be? Do the incorrectly disabled items become enabled after you do something like open and close the Help window?
There isn't an API to retrieve and use the paste mode and paste location, is there?
No, I didn't see any need to provide a way to change those settings via a script. Any particular reason why that would be useful?

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » January 17th, 2016, 6:24 pm

Andrew wrote:No, I didn't see any need to provide a way to change those settings via a script. Any particular reason why that would be useful?
Well, usually, no. I'm trying to emulate Golly with a Golly script (...) Which gives all the fuss...
Andrew wrote:
Scorbie wrote:3. Quit the script and you'll see some menus in all tabs (by tabs I mean View, Edit, ... tabs.) are disabled (grayed off)
I can't reproduce this problem on my Mac. Can you give a specific example of a menu item that has become disabled that shouldn't be? Do the incorrectly disabled items become enabled after you do something like open and close the Help window?
Hmm, that is strange. Now I don't see it... Well the symptom was that (at least) the 'Run Clipboard' becomes disabled. (And it cannot be as it contains the script to run.) I'll report any other specific conditions if I see it again.
Best wishes to you, Scorbie

User avatar
Andrew
Moderator
Posts: 764
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Andrew » February 11th, 2016, 8:45 am

Scorbie wrote:Got 'key M none' instead of 'key m shift'. ... I'm on 32bit Linux and use Lubuntu.
I get "key m shift" on my Linux system (32-bit Mint), perhaps because it's running as a VM on my Mac.

Like you, I do see that ctrl+N/O/S/Q are not removed from the File menu while the script is running, but unlike you I get the correct info returned by getevent() if I type one of those shortcuts -- ie. "key s ctrl" if I type ctrl+S.

Those 4 File menu shortcuts are somehow treated as special. They remain in the menu even if you use Prefs > Keyboard and do things like type ctrl+S and set its action to NONE.

Sorry, but I don't think I can do anything about these weird Linux differences.

User avatar
Scorbie
Posts: 1389
Joined: December 7th, 2013, 1:05 am

Re: g.getevent() ambiguous documentation in golly-2.7-gtk

Post by Scorbie » February 11th, 2016, 9:30 am

Thanks for trying. This is a very very very specific minor issue so I think it wouldn't be a catastrophe for leaving that alone for now.
Best wishes to you, Scorbie

Post Reply