From 36a18758c4760cece4837f2701e135cbd06f55da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 24 Sep 2012 16:45:58 +0200 Subject: [PATCH] On enter and leave set value only for focused widget Other widgets could be in a not valid state but we don't want to force to resolve them on such event. --- tryton/gui/window/view_form/view/form.py | 8 +++++--- tryton/gui/window/view_form/view/form_gtk/interface.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py index bd0d89d06e..caadb3f9ef 100644 --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -74,14 +74,16 @@ class ViewForm(ParserView): for widget in widgets: widget.cancel() - def set_value(self): + def set_value(self, focused_widget=False): record = self.screen.current_record if record: for name, widgets in self.widgets.iteritems(): if name in record.group.fields: field = record.group.fields[name] for widget in widgets: - widget.set_value(record, field) + if (not focused_widget + or widget.widget.get_focus_child()): + widget.set_value(record, field) def sel_ids_get(self): if self.screen.current_record: @@ -167,7 +169,7 @@ class ViewForm(ParserView): def leave(self, widget, event): # leave could be called during event process - gobject.idle_add(self.set_value) + gobject.idle_add(self.set_value, True) def button_clicked(self, widget): record = self.screen.current_record diff --git a/tryton/gui/window/view_form/view/form_gtk/interface.py b/tryton/gui/window/view_form/view/form_gtk/interface.py index b669d82d5a..ac5edef95d 100644 --- a/tryton/gui/window/view_form/view/form_gtk/interface.py +++ b/tryton/gui/window/view_form/view/form_gtk/interface.py @@ -166,7 +166,7 @@ class WidgetInterface(object): def enter(self, widget, event): if self.view: - self.view.set_value() + self.view.set_value(focused_widget=True) class TranslateDialog(NoModal):