Skip to content

fix: an open menu is not skipped like a closed one in the AX walk - #70

Open
bluzername wants to merge 1 commit into
awlevin:mainfrom
bluzername:fix-open-menu-invisible
Open

bluzername wants to merge 1 commit into
awlevin:mainfrom
bluzername:fix-open-menu-invisible

Conversation

@bluzername

Copy link
Copy Markdown

Fixes part of #58 (bug 6, "An open menu is invisible").

AX_SKIP_SUBTREE_ROLES always skip AXMenu subtrees. That is right for a closed menu, it report a zero-size frame and thousands of items, none on screen. But an open menu has a real frame on the display, so it get skipped too, and clicker never see its items. With TextEdit's File menu open, clicker could not find New.

Fix: only skip an AXMenu subtree when its frame is not real and on display. A closed menu still skip (frame has no size, so clickable() and the display check both say no), an open one is now walked like any other subtree.

-        if role in AX_SKIP_SUBTREE_ROLES:
+        if role in AX_SKIP_SUBTREE_ROLES and not (clickable(frame) and not off_display(frame, display_w_pt, display_h_pt)):
             continue

Test (TDD): added test_walks_into_an_open_menu_whose_frame_is_real_and_on_the_display in tests/test_ax.py, a menu with a real on-screen frame and one menu item. Confirmed RED on main (the menu item was missing from found), then fixed ax_walk.py and confirmed GREEN. The existing closed-menu test (test_skips_closed_menu_subtrees_but_keeps_the_menu_bar_item) still pass unchanged, it did not need touching.

Verification: uv run ruff check . && uv run ruff format --check . clean, uv run pytest -q: 731 passed, 2 skipped, 1 xfailed (one more pass than main's 730, the new test).

🤖 Generated with Claude Code

Fixes part of awlevin#58 (bug 6, "An open menu is invisible").

AX_SKIP_SUBTREE_ROLES always skip AXMenu subtrees. That is right for a
closed menu, it report a zero-size frame and thousands of items, none on
screen. But an open menu has a real frame on the display, so it get
skipped too, and clicker never see its items. With TextEdit's File menu
open, clicker could not find New.

Fix: only skip an AXMenu subtree when its frame is not real and on
display. A closed menu still skip (frame has no size, so clickable()
and the display check both say no), an open one is now walked like
any other subtree.

Test: added test_walks_into_an_open_menu_whose_frame_is_real_and_on_the_display
in tests/test_ax.py, a menu with a real on-screen frame and one menu item.
Confirmed RED on main (menu item was missing from found), then fixed
ax_walk.py and confirmed GREEN. The existing closed-menu test
(test_skips_closed_menu_subtrees_but_keeps_the_menu_bar_item) still pass
unchanged, it did not need touching.

Verification: uv run ruff check . && uv run ruff format --check . clean,
uv run pytest -q: 731 passed, 2 skipped, 1 xfailed (one more pass than
main's 730, the new test).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant