diff --git a/dzgui/views/mixins/cursor_mixin.py b/dzgui/views/mixins/cursor_mixin.py index 8c2bd32..71d4851 100644 --- a/dzgui/views/mixins/cursor_mixin.py +++ b/dzgui/views/mixins/cursor_mixin.py @@ -37,7 +37,11 @@ class CursorMixin: end = len(model) - 1 else: return False - cur_row = self.get_focused_row_index() # type: ignore + + try: + cur_row = self.get_focused_row_index() # type: ignore + except Exception: + return False if position == CursorPosition.DOWN: if cur_row == end: diff --git a/dzgui/views/pages/keys.py b/dzgui/views/pages/keys.py index 0c75c32..ea12476 100644 --- a/dzgui/views/pages/keys.py +++ b/dzgui/views/pages/keys.py @@ -103,4 +103,4 @@ class Keybindings(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore return grid def grab_content_area(self) -> None: - self.box.grab_focus() + self.grab_focus() diff --git a/dzgui/views/pages/offline.py b/dzgui/views/pages/offline.py index fcc70a2..f5baa9d 100644 --- a/dzgui/views/pages/offline.py +++ b/dzgui/views/pages/offline.py @@ -521,3 +521,6 @@ class OfflineLoader(Gtk.Box): self.mission_frame.present_folder_changed(mission) return self.offline_man.launch(appid, mission, local_mods, custom_folder, custom_mods) + + def grab_content_area(self) -> None: + self.local_frame.tree.grab_focus() diff --git a/dzgui/views/pages/options.py b/dzgui/views/pages/options.py index 54e205c..c8f482a 100644 --- a/dzgui/views/pages/options.py +++ b/dzgui/views/pages/options.py @@ -20,11 +20,13 @@ from dzgui.const.enum import Preferences, ServerTab from dzgui.strings import errors, options from dzgui.util import strings, css, open_links +from dzgui.views.components.box import VBox from dzgui.views.components.labels import LeftLabel from dzgui.views.components.buttons import WebButton from dzgui.views.components.frame import HeadingFrame from dzgui.views.components.misc import ClientCombo from dzgui.views.dialogs.generic import ExceptionDialog +from dzgui.views.mixins.scrollable_mixin import ScrollableMixin import gi @@ -44,10 +46,9 @@ class ShortHBox(Gtk.Box): self.pack_start(widget, NO_EXPAND, NO_FILL, NO_PADDING) -class Options(Gtk.Box): +class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore def __init__(self, controller: "Controller"): super().__init__( - orientation=Gtk.Orientation.VERTICAL, margin_start=10, margin_end=10, ) @@ -60,11 +61,6 @@ class Options(Gtk.Box): self.DEFAULT_WIDTH = 1 self.DEFAULT_HEIGHT = 1 - label = Gtk.Label(label=strings.options.header) - label.set_halign(Gtk.Align.CENTER) - css.add_class(label, "page-heading") - self.add(label) - self.steam_entry: Gtk.Entry self.steam = WebButton(label=strings.options.steam_web) @@ -165,9 +161,16 @@ class Options(Gtk.Box): grid.attach(frame, col, row, self.DEFAULT_WIDTH, self.DEFAULT_HEIGHT) row += 1 - self.scrollable = Gtk.ScrolledWindow(vexpand=True) - self.scrollable.add(grid) - self.add(self.scrollable) + label = Gtk.Label(label=strings.options.header) + label.set_halign(Gtk.Align.CENTER) + css.add_class(label, "page-heading") + + box = VBox() + box.add(label) + box.add(grid) + self.add(box) + + self.connect("key-press-event", self._on_keypress) def get_client_name(self) -> str: model = self.client_combo.get_model() @@ -442,4 +445,4 @@ class Options(Gtk.Box): widget.set_visibility(state) def grab_content_area(self) -> None: - return + self.grab_focus()