Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/python/gladevcp/tooledit_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def validate_input(self, path, new_text, col):

if col in(1,2):
try:
self.model[path][col] = int(new_text)
self.model[path][col] = abs(int(float(new_text.replace(',', '.'))))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abs() silently flips the sign instead of rejecting negative input: typing -3 is stored as +3 with no feedback. Since the stated intent is to match Axis, note that Axis rejects negative pocket numbers with an error rather than flipping the sign. A >= 0 check with reject would match that behavior. This widget is shared with axis, gscreen and qtdragon, so the sign-flip applies to direct cell edits there too. Also, hansu's point about pocket = -1 to disable a tool is still open in the discussion; abs() would make that impossible to express.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say much about the use of pockets as I don't use a tool changer. But A valid point is to reject negative values rather than inverting them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction on my earlier claim: the gladevcp ToolEdit widget is embedded only in gscreen and gmoccapy. Axis and qtvcp launch the standalone Tcl tooledit, which is a separate codebase, so this change does not affect them.

On rejecting vs truncating: refusing to accept wrongly formatted numbers seems fine to me, they might be genuine typos and a reject makes the user look twice. Silent truncation or sign-flip hides that.

except:
pass
# validate input for float columns
Expand Down
8 changes: 6 additions & 2 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2101,11 +2101,12 @@ def on_tool_col_edit_started(self, widget, filtered_path, new_text, col):
toolpage = self.widgets.tooledit1
toolview = toolpage.view1
model, treeiter = toolview.get_selection().get_selected()
integer_cols = [1,2,15]
value = self.dialogs.entry_dialog(self,
data=model[treeiter][col],
header=_("Enter value"),
label=_("Tool") + f" {model[treeiter][1]}, {captations[col]}:",
integer=col in [1,2,15])
integer=col in integer_cols)
if value == "ERROR":
LOG.debug("conversion error")
self.dialogs.warning_dialog(self, _("Conversion error !"),
Expand All @@ -2118,7 +2119,10 @@ def on_tool_col_edit_started(self, widget, filtered_path, new_text, col):
# Clicking on a cell emits 'editing-started' which leads to the evaluation of the text in edit mode.
# To use the return value of the calculator, it must be pretended that there is no editable (=no edit mode).
self.widgets.tooledit1.editable = None
self.widgets.tooledit1.validate_input(row, f"{value:11.4f}", col)
if col in integer_cols:
self.widgets.tooledit1.validate_input(row, f"{value:11d}", col)
else:
self.widgets.tooledit1.validate_input(row, f"{value:11.4f}", col)
self.widgets.tooledit1.edited = True
# this is needed to get offsetview out of editing mode
GLib.timeout_add(50,
Expand Down