sistemati editing di campi numeri
This commit is contained in:
parent
0c4c1e27ea
commit
b7507d95ac
@ -146,6 +146,7 @@ class MonitorApp(tk.Frame):
|
|||||||
self.detail_selected_label = getattr(self, 'detail_selected_label', None)
|
self.detail_selected_label = getattr(self, 'detail_selected_label', None)
|
||||||
self.detail_accessors = getattr(self, 'detail_accessors', {})
|
self.detail_accessors = getattr(self, 'detail_accessors', {})
|
||||||
self._flash_items = getattr(self, '_flash_items', {})
|
self._flash_items = getattr(self, '_flash_items', {})
|
||||||
|
self._fields_being_edited = set() # Track fields being edited to prevent refresh overwrite
|
||||||
self._last_detail_update = 0.0
|
self._last_detail_update = 0.0
|
||||||
try:
|
try:
|
||||||
self.detail_tree.tag_configure('changed', background='lightyellow')
|
self.detail_tree.tag_configure('changed', background='lightyellow')
|
||||||
@ -524,9 +525,11 @@ class MonitorApp(tk.Frame):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Add instant callback for editable entries (on Return key or focus loss)
|
# Add instant callbacks for editable entries
|
||||||
ent.bind('<Return>', lambda e, path=full: self._on_field_changed(path))
|
# Mark as being edited when focused, apply when done
|
||||||
ent.bind('<FocusOut>', lambda e, path=full: self._on_field_changed(path))
|
ent.bind('<FocusIn>', lambda e, path=full: self._on_entry_focus_in(path))
|
||||||
|
ent.bind('<Return>', lambda e, path=full: self._on_entry_finished(path))
|
||||||
|
ent.bind('<FocusOut>', lambda e, path=full: self._on_entry_finished(path))
|
||||||
ent.pack(side=tk.RIGHT, fill=tk.X, expand=True)
|
ent.pack(side=tk.RIGHT, fill=tk.X, expand=True)
|
||||||
widget = ('entry', ent)
|
widget = ('entry', ent)
|
||||||
|
|
||||||
@ -537,6 +540,23 @@ class MonitorApp(tk.Frame):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _on_entry_focus_in(self, field_path):
|
||||||
|
"""Mark entry as being edited to prevent refresh from overwriting user input."""
|
||||||
|
try:
|
||||||
|
self._fields_being_edited.add(field_path)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _on_entry_finished(self, field_path):
|
||||||
|
"""Entry editing finished - apply value and allow refresh again."""
|
||||||
|
try:
|
||||||
|
# Apply the change first
|
||||||
|
self._on_field_changed(field_path)
|
||||||
|
# Remove from editing set so refresh can update it again
|
||||||
|
self._fields_being_edited.discard(field_path)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def _on_field_changed(self, field_path):
|
def _on_field_changed(self, field_path):
|
||||||
"""Callback when user changes a field value - apply change immediately to message."""
|
"""Callback when user changes a field value - apply change immediately to message."""
|
||||||
try:
|
try:
|
||||||
@ -1546,6 +1566,10 @@ class MonitorApp(tk.Frame):
|
|||||||
|
|
||||||
for full, widget in list(self.form_widgets.items()):
|
for full, widget in list(self.form_widgets.items()):
|
||||||
try:
|
try:
|
||||||
|
# Skip fields that are currently being edited by user
|
||||||
|
if full in getattr(self, '_fields_being_edited', set()):
|
||||||
|
continue
|
||||||
|
|
||||||
# resolve the value from msg
|
# resolve the value from msg
|
||||||
val = None
|
val = None
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user