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:
parent
354faca838
commit
6d5e99a114
52 changed files with 372 additions and 533 deletions
|
|
@ -41,14 +41,14 @@ class Draggable(mcrfpy.Frame):
|
|||
self.tick.stop()
|
||||
|
||||
def minmax(self, pos, btn, event):
|
||||
if event != "start": return
|
||||
if event != mcrfpy.InputState.PRESSED: return
|
||||
self.minimized = not self.minimized
|
||||
self.minimize_btn.children[0].text = "+" if self.minimized else "-"
|
||||
self.clock.visible = not self.minimized
|
||||
self.h = 40 if self.minimized else 150
|
||||
|
||||
def toggle_move(self, *args):
|
||||
if not self.dragging and args[-1] == "start":
|
||||
if not self.dragging and args[-1] == mcrfpy.InputState.PRESSED:
|
||||
self.dragging = True
|
||||
self.drag_start_pos = args[0]
|
||||
self.on_move = self.update_pos
|
||||
|
|
@ -66,7 +66,7 @@ class Draggable(mcrfpy.Frame):
|
|||
self.clock.text = f"{str(self.time//60).zfill(2)}:{str(self.time%60).zfill(2)}"
|
||||
|
||||
def spawn(*args):
|
||||
if args[-1] != "start": return
|
||||
if args[-1] != mcrfpy.InputState.PRESSED: return
|
||||
scene.children.append(Draggable((50, 100)))
|
||||
|
||||
add_btn = mcrfpy.Frame((5, 5), (32, 32), fill_color = (64, 12, 12), children=[mcrfpy.Caption((8, 0), text="+", font=mcrfpy.default_font, font_size=24)])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue