Skip to content
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

cursor position can go into negative #18

Open
retroisbest opened this issue Mar 27, 2017 · 1 comment
Open

cursor position can go into negative #18

retroisbest opened this issue Mar 27, 2017 · 1 comment

Comments

@retroisbest
Copy link

When all text has been deleted the cursor should stop at position 0, but it allows it to go into negative numbers.

to fix this i edited jsKeyboard.js

added below line 26

jsKeyboard.setcurrentElementCursorPosition = $(this).setCursorPosition(0);

amended the del: function() to force the cursor position back to 0 if it goes to anything less than.

del: function() {
var a = jsKeyboard.currentElement.val(),
pos = jsKeyboard.currentElementCursorPosition,
output = [a.slice(0, pos-1), a.slice(pos)].join('');
jsKeyboard.currentElement.val(output);
//below if statement added to reset cursor position
if (pos <= 0) {
pos = "0";
//set cursor position set at top of this script if it goes below 0 the set it back to 0
jsKeyboard.setcurrentElementCursorPosition;
jsKeyboard.updateCursor();
} else {
jsKeyboard.currentElementCursorPosition--; //-1 cursor
jsKeyboard.updateCursor();
}},

cursor position always gets reset to 0 now when it goes to negative numbers.
Hope this helps
Thanks

@sdeering
Copy link
Owner

Feel free to submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants