Issue 10956

Title
Point of numeric pad does not work as decimal separator in Windows
Priority
bug
Status
resolved
Nosy list
ced, reviewbot, roundup-bot, smn
Assigned to
ced
Keywords
backport, patch, review

Created on 2021-11-13.22:53:24 by smn, last changed yesterday by roundup-bot.

Files

File name Uploaded Type Details
error.jpg smn, 2021-11-18.13:49:03 image/jpeg view
patch.diff smn, 2021-11-18.10:38:39 text/plain view

Messages

New changeset c2df6fdbe2b7 by Cédric Krier in branch 'default':
Stop key-press-event and insert decimal point
https://hg.tryton.org/tryton-env/rev/c2df6fdbe2b7
New changeset 8fe7c0da7202 by Cédric Krier in branch 'default':
Stop key-press-event and insert decimal point
https://hg.tryton.org/tryton/rev/8fe7c0da7202
Author: [hidden] (smn)
Date: 2021-11-27.09:33:46

Tested on Windows.
LGTM

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-11-26.23:19:48

Here is review374311002 which stop the key-press-event and insert the decimal point directly in the buffer. It seems to be the only way on Windows (changing keyval or re-emit a new KEY_PRESS event do not work).

Author: [hidden] (smn)
Date: 2021-11-18.13:49:03

FYI:

  • in version 5.0.27 keypad point works as decimal separator.
  • in version 5.0.28 the client crashes at startup (see attached error) and I cannot test it.
  • in version 5.0.29 keypad point does not work as decimal separator.
Author: [hidden] (smn)
Date: 2021-11-18.10:38:39

I applied attached patch.diff on branch 6.0 but same result in Windows, nothing changes (the point is not replace by comma).

On the other hand using override gets the error described in https://bugs.tryton.org/issue10956#msg71702

Author: [hidden] (smn)
Date: 2021-11-17.23:05:18

I added:

__gsignals__ = { 'key_press_event': 'override' } def do_key_press_event(self, event): if event.keyval == Gdk.keyval_from_name('KP_Decimal'): event.keyval = int(Gdk.unicode_to_keyval(ord(self.__decimal_point))) Gtk.Entry.do_key_press_event(self, event)

But give an error on last line:

`
ERROR:tryton.common.common: File "/home/smorillo/code/tryton/tryton/common/number_entry.py", line 75, in do_key_press_event
Gtk.Entry.do_key_press_event(self, event)

TypeError: argument event: Expected Gdk.EventKey, but got gi.overrides.Gdk.Event
`

Similar error described here but no answer:
https://stackoverflow.com/questions/53089621/gobject-override-signal-in-gtk

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-11-16.23:04:37

So I guess there have been a change in Gtk which prevent now to change the keyval this way. Maybe the event is already processed.
We should try: https://stackoverflow.com/questions/3161317/how-to-transform-a-key-pressed-into-a-different-one-in-pygtk

Also CellRendererFloat is probably also not working anymore.

Author: [hidden] (smn)
Date: 2021-11-16.22:41:32

Conclusions of [msg71690](msg71690):
* pressing dot key on numeric pad returns keyval of KP_Decimal (65454).
* method __key_press_event is converting correctly the XP_Decimal to keyval 44. But the point is not replaced by a comma in the field.
* the problem is not in method __key_press_event

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-11-16.22:21:03

I do not understand what should be understood by msg71690

Author: [hidden] (smn)
Date: 2021-11-16.20:19:53

I added this code to log the keyval:
def __key_press_event(self, event): with open('C:/test/tryton.log', 'a') as log: log.write('>> enter on __key_press_event\n') log.write('event.keyval: %s\n' % event.keyval) for name in ['KP_Decimal', 'KP_Separator']: with open('C:/test/tryton.log', 'a') as log: log.write('Keyval from name %s: %s\n' % (name, Gdk.keyval_from_name(name))) if event.keyval == Gdk.keyval_from_name(name): with open('C:/test/tryton.log', 'a') as log: log.write('>>match!\n') event.keyval = Gdk.unicode_to_keyval(ord(self.__decimal_point)) with open('C:/test/tryton.log', 'a') as log: log.write('%s\n' % str(event.keyval))

Typing "2.6" with numeric pad:
``

enter on __key_press_event
event.keyval: 65458
Keyval from name KP_Decimal: 65454
Keyval from name KP_Separator: 65452
>> enter on key_press_event
event.keyval: 65454
Keyval from name KP_Decimal: 65454
match!
44
Keyval from name KP_Separator: 65452

enter on __key_press_event
event.keyval: 65462
Keyval from name KP_Decimal: 65454
Keyval from name KP_Separator: 65452
enter on __key_press_event
event.keyval: 65289
Keyval from name KP_Decimal: 65454
Keyval from name KP_Separator: 65452
``

So the keyval name is "KP_Decimal".
If I press comma key the event.keyval=44.

Author: [hidden] (smn)
Date: 2021-11-16.11:56:07

ACK.
I will add here the log info.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-11-16.10:22:53

The client does not care about the host locale configuration.
So I'm pretty sure that the problem is that the keyval is not one of the supported. We can not guess which one is send, we need to have the logged value.

Author: [hidden] (smn)
Date: 2021-11-16.08:47:18

It is not clear what you mean by "does not work".
Sorry,
"does not work" => entering a quantity or a price in Tryton client, when user presses dot key on numeric pad it enters a point which is not converted to the decimal separator for his Windows language/regional configuration. In case of Spanish, this point should be represented as comma.

But I guess that on Windows it is a different keyval that is sent than the two managed for now: https://hg.tryton.org/tryton/file/default/tryton/common/number_entry.py#l72.

As I comment before in prior versions of 5.0 it converts point to decimal separator. Could be this commit change the behaviour?:
https://github.com/tryton/tryton/commit/bf073adfafa00cb9c15cc684f3af8af39f6f56cd#diff-fc1ac2b5c736886b498fdb7215605924e7604c6df277d366b327aedc7c74614d

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-11-15.22:53:30

It is not clear what you mean by "does not work".
But I guess that on Windows it is a different keyval that is sent than the two managed for now: https://hg.tryton.org/tryton/file/default/tryton/common/number_entry.py#l72.

Author: [hidden] (smn)
Date: 2021-11-13.22:53:23

I've noticed the dot key on numeric pad does not work as language decimal separator in current versions of Tryton GTK client for Windows. In Spanish, it is not replaced by comma.
Tested in last versions of 6.0, 6.2 and 5.0.
In previous releases of 5.0 (for instance 5.0.12) it worked, I reviewed commits from 5.0.12 and 5.0.41 but I don't see which can produce the bug.

History
Date User Action Args
2021-12-06 23:38:07roundup-botsetmessages: + msg72016
2021-12-06 23:38:04roundup-botsetmessages: + msg72015
nosy: + roundup-bot
status: testing -> resolved
2021-11-27 09:33:46smnsetmessages: + msg71884
2021-11-26 23:27:45reviewbotsetmessages: + msg71883
nosy: + reviewbot
2021-11-26 23:21:33cedlinkissue10988 superseder
2021-11-26 23:19:48cedsetassignedto: ced
keyword: + backport, review
messages: + msg71881
reviews: 374311002
status: chatting -> testing
2021-11-18 13:49:03smnsetfiles: + error.jpg
messages: + msg71711
2021-11-18 10:38:40smnsetfiles: + patch.diff
keyword: + patch
messages: + msg71705
2021-11-17 23:05:18smnsetmessages: + msg71702
2021-11-16 23:04:37cedsetmessages: + msg71693
status: need-eg -> chatting

Showing 10 items. Show all history (warning: this could be VERY long)