Conversation
Removes usage of old mouse enum. Introduces new mouse built-in object that is backwards compatible with old mouse enum. Old projects can stay the same and should continue working. Functions of new mouse: - `mouse.pressed` to get a tuple of all button states. - `mouse.pressed_left` to get just the state of the left mouse button. `pressed_right` and `pressed_middle` are also available. - `mouse.pos` gives the current position. Can also be set to change the mouse position. - `mouse.rel` gives the last relative position change of the mouse. - `mouse.visible` gives the boolean of the visibility state. Can also be set. - `mouse.focused` gives the boolean of whether the window is focused. - `mouse.cursor` gives the current cursor name if it is of type `system` or a custom cursor image. Can also be set to a few different system cursors or a custom image. If a custom image is used, a hotspot can be given as well. - `mouse.cursor_name` gives just the name of the cursor. Can't be set. Same goes for `mouse.cursor_hotspot`. Functionality of a deque of recent positions as well as updated documentation will be added in further commits.
Added deques of the last relative position changes by mouse-move events as well as the absolute positions after all those movements. - `mouse.recent_rel` and `mouse.recent_pos` to access a tuple of those movements. - `mouse.recent_rel_max` and `mouse.recent_pos_max` control how many move events back are recorded. Reworked the majority of attributes to perform better and more consistently. - `mouse.pressed` is now not recalculated every call. Same goes for the individual buttons. - Same for `mouse.pos` and `mouse.rel`. Rel additionally sums the relative movement of all move events over one frame which makes it consistent with calling `pygame.mouse.get_rel()` every frame. - To retain the function of `get_rel()` separately, `mouse.last_called_rel` and `mouse.last_called_pos` were added. These give the position and relative change from when they were last accessed.
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.
New mouse functionality