numericupdown problem with "es-ES" culture

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

Hi, i’m having problems with numericupdown control in “es-ES” culture, for example:

if enter (with numeric keyboard) :

0.02 –> Press tab key –> 0,0200

0.0223 –> Tab –> 0,0223

0.2 –> Tab –> 0,2000

0.025 –> Tab –> 25,0000

1.235 –> Tab –> 1235,0000 

only when number entered have three decimals.

when use: “culture”:  “en-US”  in Default.json all works ok.

 

Thanks,

Mariano

Attachment
  • You must to post comments
0
0

Hi Luca, sorry, forget to mention that i replaced numeric control with textbox control, anyway user can enter multiple commas, so validation before save data is needed.
I think is better replace ‘.’ for ‘,’ in the event but I don´t know how to replace a keyCode in keyDown event.

Thanks,

Mariano

  • Luca (ITG)
    You can’t replace the key code in the native browser event. But you can find out the location of the caret using this.getTextSelectionStart().
  • Mariano
    Thanks Luca, now solved problem when the caret is in the middle of the number, using getTextSelectionStart.
  • You must to post comments
0
0

Hi Mariano,

The  NumericUpDown control in Wisej already only allows numbers, delete, arrows, dots and commas. The javascript code you posted would only append the “,” when pressing the dot, but it doesn’t work when the caret is in the middle of the number.

Best,

Luca

  • You must to post comments
0
0

Hi, in client side possible solution is permit only numbers, back, delete, tab, arrows and convert dot to comma, not use keypress event because keycode for ‘dot’ and ‘delete’ keys are same (46)

// attach the keydown event.
// this = the widget that corresponds to the
// control on the server.

this.addListener("keydown", function(e)
{
    // get the identifier for the presses key.
    // see https://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-KeyboardEvent-keyIdentifier
    
    var code = e.getKeyCode();
    if (((code>34 && code<41) || code==8 || code==9) || code==188 || code==110 || code==190 ||  (code>=44 && code<=57) || (code>=96 && code<=105))
    {   
        if (code==110 || code==190)
        {
            this.setValue(this.getValue() + ",");
            // stop the event from propagating.
            e.stop();
        }
    }
    else
    {
        // stop the event from propagating.
        e.stop();
    }
});

 

Regards,

Mariano

  • You must to post comments
0
0

Hi Mariano,

This is a common problem with localization mismatch between the client OS and the formatting/parsing locale used by the app. It’s not a Wisej issue. It happens in .NET, Java, javascript, etc. Many years ago one app we migrated to .NET (WinForms) for a cargo company generated a manifest loading the boat 1000 times more than it could take, on paper. 🙂

The problem is your OS/keyboard is set to en-US and converts the dot from the keypad to a decimal point but the app expects a decimal comma. “0.025” converts to 25. You can verify this by parsing the string “0.025” using es-ES in .NET as well. Somehow the javascript parser is able to understand that 0.0223 is 0,0223. But if you try the same in .NET  you get 223. They are both wrong and correct at the same time.

If you enable the language bar in Windows you can switch the kayboard layout and have the decimal comma instead of the decimal point (or thousand separator).

HTH

Best,

Luca

  • Mariano
    Hi Luca, ok, I am surprised to see that only fail with three decimal numbers, change keyboard layout is not an option (from final users point of view) so i included some validation code in Validating control event and now it’s ok, do you think is better to use client side? if yes, can provide me with some code snippet that intercept keypress ‘.’ and replace with ‘,’ via qooxdoo? Thanks, Mariano
  • You must to post comments
Showing 4 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json