-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Codemirror and keyboard #551
Comments
Hi @Tophgirl! I didn't know that the demo(s) stopped working. I'll take a look. Is the backspace problem you are referring to the problem with the backspace not deleting back to the previous line? I think we can improve the demos (Codemirror and ACE editor) either way since there is now a |
Yes, that was the problem I am talking about. But I'm unsure what you are suggesting to do with the beforeInsert callback function. |
I think I figured it out, thanks for the help. |
Oh sorry, I was working on a demo on and off. If you have a solution would you please share it? |
all I did was add new keyactions to the jquery.keyboard.js file instead $keyboard.keyaction = {
//default functions ....
cmBksp: function (base) {
editor.execCommand("delCharBefore");
},
cmLineUp: function (base) {
editor.execCommand("goLineDown");
},
cmLineDown: function (base) {
editor.execCommand("goLineUp");
}
} then of course added |
Sorry, I planned on finishing the demo today. I'll try to work on it tomorrow and hopefully provide a nice solution for you. |
Ok, I think I got it! http://jsfiddle.net/Mottie/vyuuas1o/ Let me know if you discover any issues. $(function() {
var editor = CodeMirror.fromTextArea(document.getElementById("keyboard"), {
lineNumbers: true
}),
inf = editor.getInputField();
$(inf).keyboard({
keyBinding: "mousedown touchstart",
usePreview: false,
// lockInput: true,
autoAccept: true,
alwaysOpen: true,
position: {
of: $(".CodeMirror"),
my: 'center top',
at: 'center bottom',
at2: 'center bottom'
},
beforeInsert: function(evnt, keyboard, elem, txt) {
var position = editor.getCursor();
if (txt === "\b") {
editor.execCommand("delCharBefore");
}
if (txt === "\b" && position.ch === 0 && position.line !== 0) {
elem.value = editor.getLine(position.line) || "";
txt = "";
}
return txt;
}
});
}); |
Interesting, thank you. |
I know this was closed, but looking back at: #306
I want to be able to fix the backspace problem.
Something simple like this works using Codemirror commands:
<script> function backOne() {editor.execCommand("delCharBefore"); } </script>TestCmd
Unlike with$.extend($ .keyboard.keyaction)
But in order for this to work with the keyboard buttons, I need help figuring out how to set the data-action to null, and adding this function to the button.
The text was updated successfully, but these errors were encountered: