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

Various improvements and bugfixes #377

Merged
merged 6 commits into from
Aug 12, 2015
Merged

Various improvements and bugfixes #377

merged 6 commits into from
Aug 12, 2015

Conversation

insightfuls
Copy link
Contributor

Sorry, I'm a bit of a github n00b, so not sure how to submit these commits as separate pull requests.

Here's the lowdown on what these changes do:

  • Don't stop repeating when touch moves within the same key: This fixes an issue we were experiencing on Chrome on Android, I believe. Unless you held your finger very still, a touchmove event would stop the key repeat. This change checks if you're moving within or outside of the repeating key, and only stops the repeating if you've moved outside.
  • Add option to avoid focusing the input: This is pretty much what it says. We found that by avoiding focusing the input, and using lockInput and an onfocus handler on the input to blur it, we could avoid the built-in keyboard popping up on tablets. I've prepared a wiki change to accompany this which I'll paste below as a patch.
  • Ensure lockInput is effective when toggling: Bug fix. The readonly property was being reset by base.toggle() even when lockInput meant it should stay on.
  • Ensure caret is properly initialised and visible for an alwaysOpen keyboard + Make caret visible immediately on reveal, not just when another event occurs: some fixes to caret initialisation; before fixing, the caret wouldn't work because the .unbind() event after the alwaysOpen call to caret_setup would undo to setup, plus it would take until the first event (such as mouseleave) before findCaretPos was called and the caret actually appeared.
  • Add option to ignore Esc: as stated. Wiki diff below also.

If there are better ways to submit the wiki diffs, I'm all ears!

Would love it if these changes could be included, and happy to discuss and help as required.

Diff for noFocus:

diff --git a/Options.md b/Options.md
--- a/Options.md
+++ b/Options.md
@@ -16,7 +16,7 @@
 ## [[Usability]]

 * `alwaysOpen` - [Boolean] Keyboard will always remain visible.
-* `initialFocus` [Boolean] Give the preview initial focus when the keyboard becomes visible
+* `initialFocus` [Boolean] Give the preview initial focus when the keyboard becomes visible.
 * `stayOpen` - [Boolean] Keyboard remains open when input loses focus.
 * `usePreview` - [Boolean] Include a preview input or use the original.
 * `autoAccept` - [Boolean] Auto-accept content when clicking outside the keyboard (popup will close)
@@ -41,6 +41,7 @@
 * `repeatRate` - [Number] Rate of characters per second to add mouse/touch keys to the input area.
 * `resetDefault` - [Boolean] Resets the visible keyset to the default when the keyboard opens.
 * `openOn` - [String] Event used to open the keyboard.
+* `noFocus` [Boolean] Avoid focusing the input the keyboard is attached to.
 * `keyBinding` - [String] Mouse event used to interact with the key.
 * `useCombos` [Boolean] Allows users to type in key combos to add characters with diacritics.
 * `useWheel` [Boolean] Enable/disable mousewheel functionality (enabling still depends on the mousewheel plugin).
diff --git a/Usability.md b/Usability.md
--- a/Usability.md
+++ b/Usability.md
@@ -1,12 +1,12 @@
 Options:
-<a href="#alwaysopen">alwaysOpen</a> | <a href="#stayopen">stayOpen</a> | <a href="#usepreview">usePreview</a> |
+<a href="#alwaysopen">alwaysOpen</a> | <a href="#initialfocus">initialFocus</a> | <a href="#stayopen">stayOpen</a> | <a href="#usepreview">usePreview</a> |
 <a href="#autoaccept">autoAccept</a> | <a href="#autoacceptonesc">autoAcceptOnEsc</a> | <a href="#lockinput">lockInput</a> |
 <a href="#restrictinput">restrictInput</a> | <a href="#acceptvalid">acceptValid</a> | <a href="#tabnavigation">tabNavigation</a> |
 <a href="#enternavigation">enterNavigation</a> | <a href="#entermod">enterMod</a> | <a href="#stopatend">stopAtEnd</a> |
 <a href="#appendlocally">appendLocally</a> | <a href="#appendto">appendTo</a> | <a href="#stickyshift">stickyShift</a> |
 <a href="#preventpaste">preventPaste</a> | <a href="#carettoend">caretToEnd</a> | <a href="#scrolladjustment">scrollAdjustment</a> |
 <a href="#maxlength">maxLength</a> | <a href="#maxinsert">maxInsert</a> | <a href="#repeatdelay">repeatDelay</a> |
-<a href="#repeatrate">repeatRate</a> | <a href="#resetdefault">resetDefault</a> | <a href="#openon">openOn</a> |
+<a href="#repeatrate">repeatRate</a> | <a href="#resetdefault">resetDefault</a> | <a href="#openon">openOn</a> | <a href="#nofocus">noFocus</a> |
 <a href="#keybinding">keyBinding</a> | <a href="#useWheel">useWheel</a> | <a href="#usecombos">useCombos</a> |
 <a href="#combos">combos</a>

@@ -190,6 +190,12 @@
 * To disable this, set this value to an empty string "".
 * Default is `focus`.

+## <a name="nofocus">**noFocus**</a> - [Boolean]
+
+* Avoid focusing the input the keyboard is attached to if set to `true`.
+* Used with **openOn** set to `click` and an `onfocus` handler that calls blur(), this can help avoid the built-in keyboard popping up on touch devices (particularly avoiding performance problems on Safari).
+* The hardware keyboard will often not work when this is used.
+
 ## <a name="keybinding">**keyBinding**</a> - [String]

 * Mouse event used to interact with the key

Diff for ignoreEsc:

diff --git a/Options.md b/Options.md
--- a/Options.md
+++ b/Options.md
@@ -18,6 +18,7 @@
 * `alwaysOpen` - [Boolean] Keyboard will always remain visible.
 * `initialFocus` [Boolean] Give the preview initial focus when the keyboard becomes visible.
 * `stayOpen` - [Boolean] Keyboard remains open when input loses focus.
+* `ignoreEsc` - [Boolean] Escape does not close the keyboard.
 * `usePreview` - [Boolean] Include a preview input or use the original.
 * `autoAccept` - [Boolean] Auto-accept content when clicking outside the keyboard (popup will close)
 * `autoAcceptOnEsc` - [Boolean] Auto-accept content even if the user presses escape (only works if `autoAccept` is `true`)
diff --git a/Usability.md b/Usability.md
--- a/Usability.md
+++ b/Usability.md
@@ -1,5 +1,6 @@
 Options:
-<a href="#alwaysopen">alwaysOpen</a> | <a href="#initialfocus">initialFocus</a> | <a href="#stayopen">stayOpen</a> | <a href="#usepreview">usePreview</a> |
+<a href="#alwaysopen">alwaysOpen</a> | <a href="#initialfocus">initialFocus</a> | <a href="#stayopen">stayOpen</a> |
+<a href="#ignoreesc">ignoreEsc</a> | <a href="#usepreview">usePreview</a> |
 <a href="#autoaccept">autoAccept</a> | <a href="#autoacceptonesc">autoAcceptOnEsc</a> | <a href="#lockinput">lockInput</a> |
 <a href="#restrictinput">restrictInput</a> | <a href="#acceptvalid">acceptValid</a> | <a href="#tabnavigation">tabNavigation</a> |
 <a href="#enternavigation">enterNavigation</a> | <a href="#entermod">enterMod</a> | <a href="#stopatend">stopAtEnd</a> |
@@ -29,6 +30,11 @@
 * If `false`, the keyboard will automatically close when the input loses focus, or the user presses accept, cancel or escape.
 * Default is `false`.

+## <a name="ignoreesc">**ignoreEsc**</a> - [Boolean]
+
+* When `true`, escape does not close the keyboard.
+* Default is `false`.
+
 ## <a name="usepreview">**usePreview**</a> - [Boolean]

 * Include a preview input or use the original.
@@ -193,8 +199,8 @@
 ## <a name="nofocus">**noFocus**</a> - [Boolean]

 * Avoid focusing the input the keyboard is attached to if set to `true`.
-* Used with **openOn** set to `click` and an `onfocus` handler that calls blur(), this can help avoid the built-in keyboard popping up on touch devices (particularly avoiding performance problems on Safari).
-* The hardware keyboard will often not work when this is used.
+* Used with **openOn** set to `click` and an `onfocus` handler that blurs the input, this can help avoid the built-in keyboard popping up at all on touch devices (particularly avoiding performance problems on Safari).
+* The hardware keyboard will generally not work when this is used. Setting **lockInput** to `true` is recommended for best results.

 ## <a name="keybinding">**keyBinding**</a> - [String]

@Mottie
Copy link
Owner

Mottie commented Aug 12, 2015

Hi @isfs!

Wow, I appreciate all the work you've done. I'll review the changes and try to get this merged in soon :)

And by the way, the wiki pages are not restricted to collaborators only. You can add those changes once the new stuff gets merged.

@insightfuls
Copy link
Contributor Author

Thanks a lot, Rob, it'd be wonderful to have the changes merged. And that's cool
about the wiki, I'm happy to make those changes once you've updated the code.
Ben

On 12/08/15 9:43 PM, Rob G wrote:

Hi @isfs https://github.com/isfs!

Wow, I appreciate all the work you've done. I'll review the changes and try to get
this merged in soon :)

And by the way, the wiki pages are not restricted to collaborators only. You can
add those changes once the new stuff gets merged.


Reply to this email directly or view it on GitHub
#377 (comment).

Mottie added a commit that referenced this pull request Aug 12, 2015
Various improvements and bugfixes
@Mottie Mottie merged commit 7a57d02 into Mottie:master Aug 12, 2015
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

Successfully merging this pull request may close these issues.

2 participants