Set focus on the first focusable child of the form if no cursor is defined
issue4091 review7441003
This commit is contained in:
1 parent
6914b254b7
commit
ee7814658a
2 files changed
+10
-3
No files matched your search
@@ -373,7 +373,8 @@ class Screen(SignalEvent):
|
||||
break
|
||||
self.screen_container.set(self.current_view.widget)
|
||||
self.display()
|
||||
self.set_cursor()
|
||||
# Postpone set of the cursor to ensure widgets are allocated
|
||||
gobject.idle_add(self.set_cursor)
|
||||
|
||||
def load_view_to_load(self):
|
||||
if len(self.view_to_load):
|
||||
@@ -444,7 +445,8 @@ class Screen(SignalEvent):
|
||||
previous_view.set_default_date(record, selected_date)
|
||||
self.current_record = record
|
||||
self.display()
|
||||
self.set_cursor(new=True)
|
||||
# Postpone set of the cursor to ensure widgets are allocated
|
||||
gobject.idle_add(self.set_cursor, True)
|
||||
return self.current_record
|
||||
|
||||
def new_model_position(self):
|
||||
|
||||
@@ -8,7 +8,7 @@ from collections import defaultdict
|
||||
|
||||
from . import View
|
||||
from tryton.common.focus import (get_invisible_ancestor, find_focused_child,
|
||||
next_focus_widget)
|
||||
next_focus_widget, find_focusable_child)
|
||||
from tryton.common import Tooltips, node_attributes, ICONFACTORY
|
||||
from tryton.common.button import Button
|
||||
from tryton.config import CONFIG
|
||||
@@ -122,6 +122,7 @@ class ViewForm(View):
|
||||
vbox.pack_start(viewport, expand=True, fill=True)
|
||||
|
||||
self.widget = vbox
|
||||
self._viewport = vp
|
||||
|
||||
def parse(self, node, container=None):
|
||||
if not container:
|
||||
@@ -483,6 +484,10 @@ class ViewForm(View):
|
||||
notebook.set_current_page(0)
|
||||
if self.attributes.get('cursor') in self.widgets:
|
||||
focus_widget = self.widgets[self.attributes['cursor']][0]
|
||||
else:
|
||||
child = find_focusable_child(self._viewport)
|
||||
if child:
|
||||
child.grab_focus()
|
||||
record = self.screen.current_record
|
||||
position = reduce(lambda x, y: x + len(y), self.widgets, 0)
|
||||
if record:
|
||||
|
||||
Reference in new issue
Block a user