From ce7b1598c7b03be9deee656ef67a11ab53dbd175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 11 Mar 2014 20:04:28 +0100 Subject: [PATCH] Force focus_out when ComboBoxEntry changed The value must be set also when new item is selection because the focus-out and activate event doesn't catch all cases for example, when using only the mouse. issue3698 review4281003 --- .../gui/window/view_form/view/form_gtk/selection.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tryton/gui/window/view_form/view/form_gtk/selection.py b/tryton/gui/window/view_form/view/form_gtk/selection.py index ff66e37659..09a977b7ae 100644 --- a/tryton/gui/window/view_form/view/form_gtk/selection.py +++ b/tryton/gui/window/view_form/view/form_gtk/selection.py @@ -1,6 +1,8 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. import gtk +import gobject + from interface import WidgetInterface from tryton.common.selection import SelectionMixin, selection_shortcuts, \ PopdownMixin @@ -20,8 +22,8 @@ class Selection(WidgetInterface, SelectionMixin, PopdownMixin): selection_shortcuts(self.entry) child.connect('activate', lambda *a: self._focus_out()) - child.connect_after('focus-out-event', lambda *a: self._focus_out()) - child.connect('changed', self.send_modified) + child.connect('focus-out-event', lambda *a: self._focus_out()) + self.entry.connect('changed', self.changed) self.widget.pack_start(self.entry) self.widget.set_focus_chain([child]) @@ -30,6 +32,13 @@ class Selection(WidgetInterface, SelectionMixin, PopdownMixin): self.init_selection() self.set_popdown(self.selection, self.entry) + def changed(self, combobox): + def focus_out(): + if combobox.props.window: + self._focus_out() + # Must be deferred because it triggers a display of the form + gobject.idle_add(focus_out) + def grab_focus(self): return self.entry.grab_focus()