question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support key event cancelation

See original GitHub issue

Take this snippet to filter a TextInput’s text to numbers only:

tabris.create("TextInput", {
  keyboard: "number"
}).on("input", function(widget, text) {
  widget.set("text", text.replace(/[^\d]/g, ""));
});

After the input callback fires, the cursor is placed at the end of the TextInput (iOS) or at the beginning (Android)–see #537. Assuming this behavior is aligned so that all platforms move the cusor to the end, it still provides an undesirable UX.

For example, if a user were to enter 1256, place the cusror between 2 and 5, and type 34, the input should show 123456 but instead would show 123564. In a browser, the behavior is identical but this can be overcome by recording the <input>'s selectionStart on keydown and providing that value to HTMLInputElement.setSelectionRange() after the setting the <input>'s value on keyup.

I think this would be easiest to simply have a before:input event (as suggested in #529) which could cancel the event if the input doesn’t match the validation criteria.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cookiegurucommented, Jun 21, 2018

This is now possible with 4a2e12018e9c261127ee8579e2406a3dff58079c

0reactions
tbuschtocommented, Feb 23, 2016

Should be no problem.

On 22 February 2016 at 22:40, Tim Bond notifications@github.com wrote:

@ralfstx https://github.com/ralfstx It’s still possible without a cancellable event–you just have to read the position before transforming the value. See this example http://codepen.io/anon/pen/JGQqZx (which uses jQuery Carat https://bitbucket.org/accursoft/caret/wiki/Home). If I enter 12|34 and type “a” the carat stays between 2 and 3. Of course whether or not this approach is possible natively on the three platforms is a different story.

— Reply to this email directly or view it on GitHub https://github.com/eclipsesource/tabris-js/issues/776#issuecomment-187398507 .

Innoopract Informationssysteme GmbH tbuschto@eclipsesource.com Tel: +49 721 - 66 47 33 - 0 Fax: +49 721 - 66 47 33 29

Read more comments on GitHub >

github_iconTop Results From Across the Web

8 Event Cancellation Email Examples From Top Brands
If you're making the tough decision to cancel, we hope these examples will help you communicate your plans thoughtfully. 1. Mobile World ...
Read more >
How to Cancel an Event with the Least Drama (with Sample ...
Steps to Gracefully Cancel an Event · 1. Enlist help as quickly as possible · 2. Identify constituents · 3. Edit your event...
Read more >
How to Gracefully Cancel an Event - Eventbrite Blog
Once the final decision has been made to cancel your event, make sure to cease selling tickets immediately. This will help mitigate ...
Read more >
How To Communicate An Event Cancelation | BMG Blog
Clear communication and transparency are crucial in order to manage an event cancelation successfully. Stay positive. Be empathetic.
Read more >
Event.cancelable - Web APIs - MDN Web Docs
To cancel an event, call the preventDefault() method on the event. This keeps the implementation from executing the default action that is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found