fix(inputSelect) Improving inputSelect component usability (#26)

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2018-07-12 14:20:11 +02:00
1 parent e474fdff2c
commit 589be952b7
2 files changed
+52 -4

No files matched your search

+20
View File
@@ -68,3 +68,23 @@ OHIF.ui.getScrollbarSize = () => {
return [(w1 - w2), (h1 - h2)];
};
/**
* Check if the pressed key combination will result in a character input
* Got from https://stackoverflow.com/questions/4179708/how-to-detect-if-the-pressed-key-will-produce-a-character-inside-an-input-text
*
* @returns {Boolean} Wheter the pressed key combination will input a character or not
*/
OHIF.ui.isCharacterKeyPress = event => {
if (typeof event.which === 'undefined') {
// This is IE, which only fires keypress events for printable keys
return true;
} else if (typeof event.which === 'number' && event.which > 0) {
// In other browsers except old versions of WebKit, event.which is
// only greater than zero if the keypress is a printable key.
// We need to filter out backspace and ctrl/alt/meta key combinations
return !event.ctrlKey && !event.metaKey && !event.altKey && event.which !== 8;
}
return false;
};