jspreadsheet / ce

Jspreadsheet is a lightweight vanilla javascript plugin to create amazing web-based interactive tables and spreadsheets compatible with other spreadsheet software.
https://bossanova.uk/jspreadsheet/v4
MIT License
6.7k stars 820 forks source link

openEditor - how can we get the keypress details? #151

Closed morgunder closed 6 years ago

morgunder commented 6 years ago

have a column set up to open select2 on the keypress. but if i type in 111 i only get 11 within select2. is there a way to snag (or pass in) the keypress that caused the openEditor event to trigger? that way i think i can capture the initial 1 press.

thx

pphod commented 6 years ago

I imagine you already got this working. ;)

morgunder commented 6 years ago

yes did get this working. would you like anything from our implementation to share with others?

pphod commented 6 years ago

If you think worth, examples, anything I can publish in the website... ;)

I can create a section of user cases.

Regards,

tejcirkulate commented 5 years ago

yes did get this working. would you like anything from our implementation to share with others?

Can you please share the solution. This is coming up again at #236 and #246

koenhandekyn commented 5 years ago

a small snippet would be very helpful :)

tejcirkulate commented 5 years ago

Heres what I've tried but its not elegant because its bit of customization to the core jexcel code.

The idea is that I'd like my open editor to know that the open editor is being called due to doubleclick versus a keypress. For now, I've only changed the doubleclick handler to pass the event object to the open editor, but other handlers should change as well for interface consistency. This is against 1.5.7:

In double click handler, when calling open editor, pass the event object too. The second arg to open editor is null because it expects an empty argument also.

@@ -805,7 +805,7 @@ var methods = {

                     // Open editor action
                     if ($(e.target).is('.highlight')) {

Change the signature for open editor to accept the event object as argument:

@@ -1454,7 +1454,7 @@ var methods = {

@@ -1481,7 +1481,7 @@ var methods = { $(cell).addClass('edition');

When calling the custom editor's open editor, pass the event object along. // Custom editors