Merge pull request #3393 from InspectorCaracal/patch-22

Make EvMenu options single-column for screenreader mode
This commit is contained in:
Griatch 2024-01-08 20:49:59 +01:00 committed by GitHub
commit c0aaedc51a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1206,7 +1206,16 @@ class EvMenu:
else:
# add a default white color to key
table.append(f" |lc{raw_key}|lt|w{key}|n|le{desc_string}")
ncols = _MAX_TEXT_WIDTH // table_width_max # number of columns
# check if the caller is using a screenreader
screenreader_mode = False
if sessions := getattr(self.caller, 'sessions', None):
screenreader_mode = any(sess.protocol_flags.get("SCREENREADER") for sess in sessions.all())
# the caller doesn't have a session; check it directly
elif hasattr(self.caller, 'protocol_flags'):
screenreader_mode = self.caller.protocol_flags.get("SCREENREADER")
ncols = 1 if screenreader_mode else _MAX_TEXT_WIDTH // table_width_max
if ncols < 0:
# no visible options at all