EasyUI Forum

General Category => Bug Report => Topic started by: Afract on July 11, 2016, 12:07:34 AM



Title: NumberBox doesn't work for some keyboards layouts
Post by: Afract on July 11, 2016, 12:07:34 AM
Hello,

I found a very annoying issue with numberbox (which probably also affects some other easyui controls) : it's not possible to type numbers with AZERTY keyboards (and maybe with some others) :
- It's ok with the numeric keypad
- It's ok using the numbers above first row of chars with caps lock enabled
- But it's NOT ok while using Shift key !

You maybe asking "Why the hell does he wants to use shift key to input numbers ???"

I guess your input filtering method is intended to work for QWERTY layout.

With (at least) AZERTY keyboards layout, you have to enable CAPS to input digits using the numbers above the AZERTY line, see here for example to understand :
http://www.informatique-astuces.com/wp-content/uploads/2013/07/qwerty-azerty-correspondances-touches.jpg

Please note the AZERTY layout is used in Europa by millions of people (mainly in France but also in other countries like Belgium).

So you should NOT prevent to press the "shift" key, or it won't be possible to input numbers.

Could you please suggest me a temporary fix for this issue, and fix it in the upcoming version of easyui ?
For me it sounds like a bug.

Thank you


Title: Re: NumberBox doesn't work for some keyboards layouts
Post by: jarry on July 11, 2016, 07:31:03 AM
Please try to override the $.fn.numberbox.defaults.filter function.
Code:
<script type="text/javascript">
$.extend($.fn.numberbox.defaults,{
filter: function(e){
var opts = $(this).numberbox('options');
var s = $(this).numberbox('getText');
if (e.which == 13){ // ENTER
return true;
}
if (e.which == 45){ //-
return (s.indexOf('-') == -1 ? true : false);
}
if (e.metaKey || e.ctrlKey){
return true;
}
var tmp = $('<span></span>');
tmp.html(String.fromCharCode(e.which));
var c = tmp.text();
tmp.remove();
if (!c){
return true;
}
if (c == opts.decimalSeparator){
return (s.indexOf(c) == -1 ? true : false);
} else if (c == opts.groupSeparator){
return true;
} else if ('0123456789'.indexOf(c) >= 0){
return true;
} else {
return false;
}
}
});
</script>


Title: Re: NumberBox doesn't work for some keyboards layouts
Post by: Afract on July 11, 2016, 09:25:51 AM
Hello,
At first glance it looks to work well !

I just added
Code:
if (e.which == 8)
{
    return true;
}
To allow backspace.

Do you plan to include the fix in a coming release ?

Thank you!


Title: Re: NumberBox doesn't work for some keyboards layouts
Post by: jarry on July 11, 2016, 04:10:32 PM
The filter logic will be enhanced and included to the next version.