lordmauve / lordmauve/pgzero

Button parameter for mouse functions not correctly mapped to enum

Open
#349 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
611
Forks
211
PR merge metrics
No merged PRs in 30d

Description

While writing controller support for PGZero, I noticed that the behaviour described in the documentation string of prepare_handler in game.py does not seem to be correct. It states:

The wrapped handler will also map certain parameter values using callables from EVENT_PARAM_MAPPERS; this ensures that the value of 'button' inside the handler is a real instance of constants.mouse, which means (among other things) that it will print as a symbolic value rather than a naive integer.

The values given to the mouse functions being proper values of the mouse enum does not appear to be the case however. When running the following simple example with pgzrun, only normal integer values are printed.

def on_mouse_down(button):
    print(button)

I must admit I don't currently understand how prepare_handler really works, so I don't think I can fix this myself.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in game.py at the prepare_handler documentation and implementation, then reproduce the on_mouse_down example with pgzrun. Trace how the button parameter is passed to mouse handlers and verify that the observed value is a constants.mouse enum rather than a plain integer, with the documentation matching the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.