Remove legacy string enum comparisons from InputState/Key/MouseButton, closes #306

Removed custom __eq__/__ne__ that allowed comparing enums to legacy string
names (e.g., Key.ESCAPE == "Escape"). Removed _legacy_names dicts and
to_legacy_string() functions. Kept from_legacy_string() in PyKey.cpp as
it's used by C++ event dispatch. Updated ~50 Python test/demo/cookbook
files to use enum members instead of string comparisons. Also updates
grid.position -> grid.pos in files that had both types of changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-04-09 22:19:02 -04:00
commit 6d5e99a114
52 changed files with 372 additions and 533 deletions

View file

@ -45,11 +45,13 @@ def test_key_enum_members():
check("IE: Key enum members", test_key_enum_members)
def test_inputstate_legacy():
assert mcrfpy.InputState.PRESSED == "start"
assert mcrfpy.InputState.RELEASED == "end"
def test_inputstate_values():
assert int(mcrfpy.InputState.PRESSED) == 0
assert int(mcrfpy.InputState.RELEASED) == 1
# Legacy string comparison removed (#306)
assert mcrfpy.InputState.PRESSED != "start"
check("IE: InputState legacy string compat", test_inputstate_legacy)
check("IE: InputState enum values", test_inputstate_values)
def test_click_handler():
frame = mcrfpy.Frame(pos=(100, 100), size=(200, 50))