Merged
Conversation
caffeinepills
requested changes
May 24, 2025
Collaborator
caffeinepills
left a comment
There was a problem hiding this comment.
Looks good, just needs cleaning up.
pyglet/text/caret.py
Outdated
| self.visible = True | ||
|
|
||
| self._window = window | ||
| self.push_handlers(window) |
Collaborator
There was a problem hiding this comment.
No longer need to push the window as a handler if the Caret is dispatching. (Also the value could be None, so this would fail regardless)
pyglet/window/__init__.py
Outdated
| during runtime. | ||
| """ | ||
|
|
||
| def on_clipboard_copy(self, text: str) -> EVENT_HANDLE_STATE: |
pyglet/window/__init__.py
Outdated
| BaseWindow.register_event_type('on_file_drop') | ||
| BaseWindow.register_event_type('on_draw') | ||
| BaseWindow.register_event_type('on_refresh') | ||
| BaseWindow.register_event_type('on_clipboard_copy') |
588b4b7 to
6882533
Compare
6882533 to
0ee4e77
Compare
caffeinepills
approved these changes
Jun 11, 2025
caffeinepills
approved these changes
Jun 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Draft adds clipboard support to pyglet.
First, it adds the
on_clipboard_copyandon_clipboard_pasteevents toCaret.Then, the
Caretis now anEventDispatcher, and is registered for these events. There is a new optional window argument, which sets _window and will be used to set the clipboard content.In
on_text_motion, if the motion isMOTION_COPY, it will dispatchon_clipboard_copy, and will copy the text.If the motion is
MOTION_PASTE, it will paste the text inside the layout, overriding if something else was selected, and then dispatchingon_clipboard_pasteto the window that was passed in.Please, feel free to correct my code or even push your local changes if you want to.