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
This commit is contained in:
Cédric Krier committed 2014-03-11 20:04:28 +01:00
1 parent 168d914bdf
commit ce7b1598c7
1 file changed
+11 -2
@@ -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()