Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add escape_unfocuses field to PyCUI #145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions py_cui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def __init__(self, num_rows: int, num_cols: int, auto_focus_buttons: bool=True,
# Variables for determining selected widget/focus mode
self._selected_widget: Optional[int] = None
self._in_focused_mode = False
self._escape_unfocuses = True
self._popup: Any = None
self._auto_focus_buttons = auto_focus_buttons

Expand Down Expand Up @@ -1549,8 +1550,8 @@ def _handle_key_presses(self, key_pressed: int) -> None:

# If we are in focus mode, the widget has all of the control of the keyboard except
# for the escape key, which exits focus mode.
elif self._in_focused_mode and self._popup is None:
if key_pressed == py_cui.keys.KEY_ESCAPE:
if self._in_focused_mode and self._popup is None:
if key_pressed == py_cui.keys.KEY_ESCAPE and self._escape_unfocuses:
self.status_bar.set_text(self._init_status_bar_text)
self._in_focused_mode = False
selected_widget.set_selected(False)
Expand Down