EasyUI Forum
May 07, 2024, 09:48:24 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: NumberBox doesn't work for some keyboards layouts  (Read 8955 times)
Afract
Newbie
*
Posts: 9


View Profile
« 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 Huh"

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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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>
Logged
Afract
Newbie
*
Posts: 9


View Profile
« Reply #2 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!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: July 11, 2016, 04:10:32 PM »

The filter logic will be enhanced and included to the next version.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!