Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keybard paste from clipboard when switching to the image doesn't work first time (need to paste a second time) #16700

Closed
macta opened this issue May 27, 2024 · 13 comments

Comments

@macta
Copy link
Contributor

macta commented May 27, 2024

Bug description
When you you copy some text from an email or webrowser and then switch to the image, select a playground or method source and peform meta-v (aka paste) the paste operation doesn't work the first time, you have to meta-v a second time for it to work.

To Reproduce
On a Mac running OSX 14.x

  1. Go to a web browser and copy some text (cmd-c)
  2. Cmd-tab to a running pharo image
  3. Click on a playground
  4. Cmd-V to past the text (into doesn't appear), Cmd-v again to actually paste

Expected behavior
The initial paste operation should just work

Screenshots
n/a

Version information:

  • OS: OSX
  • Version: 14.x
  • Pharo Version P11 and P12

Expected development cost
Unsure

Additional context
This has been confirmed to happen by other OSX users on the pharo list, but needs confirmation from Windows and Linux

@macta
Copy link
Contributor Author

macta commented May 27, 2024

Also others have confirmed P10 again with OSX (and I believe these are all arm macs - so not sure if processor has a bearing)

@fuhrmanator
Copy link

I'm on Windows 10 and I have never seen this problem (pharo 10, 11).

There's one with drag-and-drop (a short-cut to open Moose models) where the first click (after dropping onto Pharo and a dialog is opened) is ignored. I think it's related to the "drop" action not bringing Pharo to the front in Windows properly (it looks to be in front because the dialog opens).

@Whalehead99
Copy link

I've had this issue for years. Yes, I've been on MacOS the entire time, but I had/have the same issue on Intel Macs as well as my current M2. I've just really gotten used to clicking twice on a pharo widget before attempting to copy. I find this most when I'm trying to add my github packages to a new image. I need to copy my github URLs into the textEntry cell, and I click on the cell, attempt a paste, then click on it again - then paste again... then it works. Hope that helps!

@macta
Copy link
Contributor Author

macta commented May 29, 2024

I'm glad it's not just me suffering this.

I swear this wasn't something I noticed in older versions of Pharo - so will go back and check P9 and P8.

I have also noticed in P12 that saving a method might have the same issue. When doing web development and flipping between a web browser to check results, several times now I've not seen my expected change and realised my change wasn't saved - which is reminiscent of the paste error. I need to confirm this as I would have successfully made some changes and it's just the save that didn't work.
Possibly the issue is in recognising the meta key vs normal keys?

@varvello
Copy link

Pharo8 hadn't the issue. I don't know about Pharo9.

Cheers
Davide

I'm glad it's not just me suffering this.

I swear this wasn't something I noticed in older versions of Pharo - so will go back and check P9 and P8.

I have also noticed in P12 that saving a method might have the same issue. When doing web development and flipping between a web browser to check results, several times now I've not seen my expected change and realised my change wasn't saved - which is reminiscent of the paste error. I need to confirm this as I would have successfully made some changes and it's just the save that didn't work. Possibly the issue is in recognising the meta key vs normal keys?

@macta
Copy link
Contributor Author

macta commented May 29, 2024

This is wierd, I loaded up an old P9 image (alongside my P12 image that had the problem when I opened this issue) to see for myself when this started happening. I copied some text from a web page, flipped to playground in P9 and it pasted fine. I flipped to P12 and I had to paste twice. I then tried it again and this time if failed in P9 and then worked in P12 - then it failed both times in both images, and then it worked fine lots of times.

After experimenting a bit - I think you have to leave the image for 10 seconds or more, copy some text and then return to the image and it might fail. I don't think its a loss of focus, as I've had it happen a few times where I could press enter and see the cursor move, paste and fail and then paste again and it worked.

So I haven't quite nailed the sequence that consistently makes this fail - but its annoying enough that it needs a fix - bit we need the guaranteed steps.

@macta
Copy link
Contributor Author

macta commented May 29, 2024

Another example I've just had a few times now on P12 - I've switch to the image (after not using it for a few minutes), the cursor is flashing in a method browser, I've pressed paste (cmd-v) multiple times and its not worked, I've use the left/right arrows to move the cursor (and confirm I've got focus where I think I should) and then paste works fine.

I've also noticed its not just cmd-v that fails, but also cmd-a (select all) or cmd-l to revert method changes. The arrow keys always seem to work and I suspect that a normal character key would as well - it seems to be meta keys that fail.

@macta
Copy link
Contributor Author

macta commented May 29, 2024

I have so far been unable to reproduce this issue in P8 or in the latest GT image - however P9 and P12 both exhibit this issue.

When I get the problem - continuing to press cmd-v (without releasing the cmd key) does not work - I have to release the cmd key, and then press cmd-v again and it will work. So I am suspecting that this is an issue with detecting the press of the cmd key - or understanding its current state - meaning that the key combination is ignored.

I'm not sure what part the window gaining focus plays on this (and its worth saying I can replicate the problem when pharo is full screen mode or just a large window on the screen (so maximise doesn't play a part).

I'm not sure if the timing between gaining focus and pressing cmd-v has any part in this - as I normally flip to pharo and then press cmd-v to paste something (I think the next thing is to see if I can replicate if I wait 2 seconds after flipping and then see if it will fail).

@macta
Copy link
Contributor Author

macta commented May 29, 2024

Another observation - I've been able to repeat the problem on P9 and P12 several times now (it seems when it gets into this state, flipping to the image time and time again will reproduce the problem. After flipping, even if you wait 5 seconds and then press cmd-v it won't paste (repeatedly) until you release and then press cmd-v again. So its something about gaining window focus and detecting the first cmd keypress that goes wrong. Having repeated it now 5 times, I've then cmd-l reset the method pane I was pasting into and now its working fine every time I flip and paste - similarly in the other image, I've cleared the palyground, typed a few characters and then flipping and pasting is working every time. So it seems like something happens that gets it into this mode where its susceptible to missing the meta key press.
After writing the above I flipped back and both images seemed to have the problem again, flipping between them, they both wouldn't paste - however I cleared the playground on one of them and then flipping to the other seemed to fix paste in it too.

Hopefully the above sequenes might shed some light on this.

@tesonep
Copy link
Collaborator

tesonep commented May 30, 2024

Hi, thanks you all so much for the report and the effort to show what is happening.
I have found a way of reproducing it.

  1. In Pharo, let the cursor and the focus somewhere we can paste.
  2. Change to other desktop using the Ctrl+Arrows
  3. Come back to Pharo's Desktop using the Ctrl+Arrows keys
  4. Before the animation of changing desktop finish press CMD and hold it
  5. without releasing CMD press V many times
  6. Nothing happens.

Releasing and pressing CMD+V starts working

This is also happening when you do a CMD+TAB change and instead of accepting the new window by releasing the CMD key, you click in the icon.

I have tracked the issue until an issue in SDL.
SDL is handling the modfiers of the keyboard by only updating them when Cocoa sends the key down/up event for that modifier. It is handling the NSEventTypeFlagsChanged event, but this event only arrives when the window has focus, so if the CMD (in this case) key is pressed while there is not focus, the modifier is not updated. So to Pharo we are getting a V, and not a CMD+V.
I am trying to patch the SDL code to confirm / dismiss this theory.

@macta
Copy link
Contributor Author

macta commented May 30, 2024

I'm relieved that you have found a usecase - its been driving me bonkers thinking that maybe my keyboard was broken.
I do wonder why in many cases I can flip to the image with a method browser showing the flashing cursor (as if it has focus) - wait 5 seconds and then do cmd-v and still have the problem? And yet other times I can do the exact same thing - wait 1 second and it works perfectly. So I wonder if there is some race condition where sometimes the Flag event happens without focus and it misdetects the true state (or something like that). Anyway - it definitely sounds like its something in this type of interaction that would explain it.

I also appreciate you having a look as its not the simplest thing to track down - and its easy to just shrug shoulders and just fix something else.

@macta
Copy link
Contributor Author

macta commented Sep 3, 2024

Many thanks for looking into this - to verify it has worked - will one of the current builds have this new sdl2 library and then I can replicated the steps above and confirm?

@jecisc
Copy link
Member

jecisc commented Sep 3, 2024

@macta From what I understood you just need to update the VM and things should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants