-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding extender resets the keyboard to the standard keyset #510
Comments
The problem is that the I guess I could add an option to override that behavior, or maybe not reset if the same main keyboard keyset is still being used. What do you think? |
Ha, thanks for your quick reply! Hmm, okay I understand now how it started out, thanks. To be honest, the first option feels like a hacky way that may introduce trouble in the future, the second option sounds better but I don't know all the use cases, so some use cases might be hurt? I guess the best way is to let it stay like this, except if you think there is no use case where somebody would like to redraw a keyboard with the same keyset! Thanks for this discussion haha |
You give up too soon grasshoppa.... If we add a variable to save the last keyset, you can reset the layout - https://jsfiddle.net/Mottie/y0hL0ea9/2/ Code from #505 with added $(function() {
var $keyboard = $('#keyboard'),
// extender layout
lastKeyset = '',
hexActive = false;
$.keyboard.layouts.numpad = {
'normal': [
'{clear} / * -',
'7 8 9 +',
'4 5 6 %',
'1 2 3 =',
'0 {dec} {left} {right}'
]
};
$.keyboard.layouts.hexpad = {
'normal': [
'C D E F',
'8 9 A B',
'4 5 6 7',
'0 1 2 3',
'x {clear} {left} {right}'
]
};
// switch extender layout
$.keyboard.keyaction.hex = function(kb) {
hexActive = !hexActive;
lastKeyset = kb.last.keyset;
// toggle hex button
$keyboard.addExtender({
layout: hexActive ? 'hexpad' : 'numpad',
// restore current state of extender
showing: kb.extender_options.showing
});
kb.redraw();
// update state of hex button
$('.ui-keyboard-hex').toggleClass(kb.options.css.buttonActive, hexActive);
};
$keyboard.keyboard({
layout: 'custom',
display: {
hex: "🐵:Hexpad",
clear: "🗑:Clear",
extender: " :Toggle Pad"
},
beforeVisible: function(e, kb) {
if (lastKeyset) {
[kb.shiftActive, kb.altActive, kb.metaActive] = lastKeyset;
kb.showKeySet();
}
},
customLayout: {
'normal': [
'` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
'{tab} q w e r t y u i o p [ ] \\',
'a s d f g h j k l ; \' {enter}',
'{shift} z x c v b n m , . / {shift}',
'{accept} {space} {cancel} {extender} {hex}'
],
'shift': [
'~ ! @ # $ % ^ & * ( ) _ + {bksp}',
'{tab} Q W E R T Y U I O P { } |',
'A S D F G H J K L : " {enter}',
'{shift} Z X C V B N M < > ? {shift}',
'{accept} {space} {cancel} {extender} {hex}'
]
}
}).addExtender({
// choose any layout
layout: 'numpad',
// start with extender showing?
showing: true,
// reposition keyboard after toggling extender layout
reposition: true
});
}); |
Oops, I threw in some array destructuring in the code... just in case you or someone else doesn't understand, these two bits of code are equivalent: [kb.shiftActive, kb.altActive, kb.metaActive] = lastKeyset;
/* the code above does the same thing as the code below */
kb.shiftActive = lastKeyset[0];
kb.altActive = lastKeyset[1];
kb.metaActive = lastKeyset[2]; |
See #505 (comment) for update... basically all this has been internalized in the extender code. |
My problem is that adding another extender resets the keyboard to the standard keyset, is this intended behaviour? In that case you can just close the issue :P But to me, it doesn't seem like that is the best standard behaviour when adding an extender, because I can imagine people wanting to add an extender to the current KeySet, without having to switch to that KeySet again after adding the Extender.
P.S. The keyset switching works really well :)
The text was updated successfully, but these errors were encountered: