Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
62934f0e by Cédric Krier at 2023-05-30T18:15:43+02:00
Set value on focus out and changed signal for datetime widget
The focus out of child widgets must call focus out method.
And we need to connect to the datetime-changed event as DateTime does not call
the __init__ method of Date.
Closes #12020
- - - - -
cc50b693 by Cédric Krier at 2023-05-30T18:26:16+02:00
Always disable scroll-event and prevent move-active on readonly time and
datetime
The time and datetime widgets were missing from 7a55ecca7a59 of #7076
- - - - -
1 changed file:
- tryton/tryton/gui/window/view_form/view/form_gtk/calendar_.py
Changes:
=====================================
tryton/tryton/gui/window/view_form/view/form_gtk/calendar_.py
=====================================
@@ -92,8 +92,13 @@
self.set_format()
+def _move_active(combobox, scroll_type):
+ if not combobox.get_child().get_editable():
+ combobox.stop_emission_by_name('move-active')
+
+
class Time(Date):
_changed_signal = 'time-changed'
def __init__(self, view, attrs):
super(Time, self).__init__(view, attrs, _entry=TimeEntry)
@@ -95,8 +100,12 @@
class Time(Date):
_changed_signal = 'time-changed'
def __init__(self, view, attrs):
super(Time, self).__init__(view, attrs, _entry=TimeEntry)
+ self.entry.connect('move-active', _move_active)
+ self.entry.connect(
+ 'scroll-event',
+ lambda c, e: c.stop_emission_by_name('scroll-event'))
def _set_editable(self, value):
self.entry.set_sensitive(value)
@@ -133,8 +142,12 @@
for child in self.entry.get_children():
add_operators(child)
if isinstance(child, Gtk.ComboBox):
+ child.connect('move-active', _move_active)
+ child.connect(
+ 'scroll-event',
+ lambda c, e: c.stop_emission_by_name('scroll-event'))
child = child.get_child()
child.set_property('activates_default', True)
child.connect('key_press_event', self.sig_key_press)
child.connect('activate', self.sig_activate)
child.connect('changed', lambda _: self.send_modified())
@@ -136,8 +149,10 @@
child = child.get_child()
child.set_property('activates_default', True)
child.connect('key_press_event', self.sig_key_press)
child.connect('activate', self.sig_activate)
child.connect('changed', lambda _: self.send_modified())
+ child.connect('focus-out-event', lambda *a: self._focus_out())
+ self.entry.connect(self._changed_signal, self.changed)
self.widget.pack_start(self.entry, expand=False, fill=False, padding=0)
@classmethod
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/ac4a998e1a2df96232bf31489ba7911bca1dcc98...cc50b693f196c5e75a4f5d635341d0805794dab8
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/ac4a998e1a2df96232bf31489ba7911bca1dcc98...cc50b693f196c5e75a4f5d635341d0805794dab8
You're receiving this email because of your account on foss.heptapod.net.