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
Blinking text cursor in bottom-left corner; mouse pointer always displayed as CURSOR_TEXT on Mac OS X. #1042
Comments
If anyone has an M1/M2 Mac and can replicate this issue, please let us know. |
I couldn't replicate this either on older Intel hardware. However, |
After a few days of investigation, I've discovered that we can't remove the Structure returns are required for these instance methods: I did find some information from a bug/request 15 years ago: python/cpython#49960 The only fix seems to be a ctypes patch from another project, but it involves overwriting internal ctypes calls, which are subject to change. Licensing aside, not sure that'd be the route to go. At this point we can assume it probably won't be patched or implemented in the immediate future. So we will have to try to hang onto the @ciraben Could you try it out and let me know if this changes anything? Thanks https://github.com/caffeinepills/pyglet/tree/macos_nstextview |
Thanks for taking the time to look into this! I know it's not your fave topic and I appreciate the dedication. Testing your workaround, it hides the text caret as expected. My mouse pointer still behaves as before, switching to the I'm not personally in need of a workaround (2.0.7 works for my needs, and I don't have any active pyglet project ATM) - but maybe the above is useful to someone anyway! FWIW, I'm getting a message that |
Appreciate you checking on that. Bummer about the cursor at least. There are still a few more tricks to try. Could you try adding this. It's supposed to set the view as uneditable, hopefully that includes the invisible selection area:
@PygletTextView.method('v@')
def mouseMoved_(self, nsevent):
send_super(self, 'mouseMoved:', nsevent) Which should capture the mouse moved from the Text view and pass it to the regular view, hopefully that intercepts any cursor change stuff going on. See if any of those change anything. I think the first option might work, but try the second to see if anything changes if not. I'd like to narrow down the issue whenever you have time. |
I have the exact same issue on a 2020 M1 MacBook pro running macOS Sonoma 14.3.1, python 3.12.2 and pyglet 2.0.14 steps to reproduce :
import pyglet
window = pyglet.window.Window()
pyglet.app.run() You can see a small blue line in the bottom-left corner of the screen. It's blinking at ~1Hz. It's my first time ever trying Pyglet, so I think I might simply downgrade until this bug is fixed, but I can totally share more details about my configuration if needed. |
I have some news ! I'm not sure exactly what happened, but I reinstalled Pyglet using pip in my environment, and I can't seem to reproduce the issue anymore ! It's really weird as the Pyglet version is the exact same, and nothing in my configuration has changed. Maybe Apple did an update of its own ? Anyways, I'll let you know if I manage to reproduce this bug again. It's now time to learn how to use the library ! |
Thanks for the feedback @HerbeMalveillante. |
Updated to master, still the same :/ |
Adding this code to the
Following the documentation of AppKit |
|
I'm still seeing the blinking cursor at the bottom right of the window. macOS 14.4.1 (23E224), pyglet |
You are right, it was only one time. Again same issue, whatever I do :/ |
I had the same issue - a blinking cursor in the bottom left corner on a macOS 14.2.1 and pyglet 2.0.15. |
Quick update here! New OS version ✨ tl;dr - blinking text cursor resolved by suggested pyglet patch above. wrong mouse cursor partly resolved by subclassing Window and setting cursor type on each mouse motion event. I tried out eruvanos' However, my mouse pointer is still reset to the I also went back and re-tested with text_input.py and I get better results now. I'm not able to replicate what I described initially back in January regarding the mouse cursor. I can't recall whether I misreported, or whether I really did see solely Anyway, I now see the correct mouse cursor ( Suspecting a race condition, I tested the following code out (based on examples/text_input.py, L69-L70): import pyglet
from time import sleep
lag = 0
# lag = 0.05
class CoolWindow(pyglet.window.Window):
def on_mouse_motion(self, x, y, dx, dy):
sleep(lag)
self.set_mouse_cursor(None)
window = CoolWindow()
pyglet.app.run() With So I think we can safely conclude that the OS and I wonder whether this race condition arises in each mouse motion event, or only when many events are triggered in quick succession. |
Following up on caffeinepills' original suggestions specifically - Adding Adding the suggested |
Describe the bug
Whenever pyglet opens a window on my machine, a text cursor flashes in the bottom-left of the window, as though the entire window is a text input box. Additionally, my mouse pointer assumes the
CURSOR_TEXT
icon when in the window, as long as the window is in focus - with exception below.If the mouse pointer is hovering over the window as it gains focus, the pointer assumes the icon selected by pyglet until mouse movement. Additionally, when moving the pointer into the window from the top, there's a small boundary (between the window rect and the window bar) within which the pointer assumes the pyglet-chosen icon.
In short, pyglet windows visibly act as textboxes on my (2 week old) machine.
This behavior first appears for me after commit 74b6bc05. pyglet 2.0.7 has no such behavior, while pyglet 2.0.8-2.0.10 does.
This seems like it may be related to this comment in cocoa/pyglet-view.py:
FWIW, removing the
self.addSubview_(self._textview)
line resolves the visual bug for me but breaks text editing in any textboxes in the window. Same with settingacceptsFirstResponder
again (reversing part of the commit). This too removes the visual bug, but prevents textboxes from being edited.All this to say, I suspect this bug is a side-effect of subclassing NSTextView. If we can figure out how to replicate this bug, it might warrant a successor to the 'easy' solution in the comments above.
System Information:
How To Reproduce
After speaking with Benjamin on Discord (thread here), I hear he's unable to replicate on his M1 macbook with Sonoma 14.2.1.
This is the code I used to test:
I also tested textbox functionality with examples/text_input.py
The text was updated successfully, but these errors were encountered: