codemirror / CodeMirror-v1

An editable-iframe based code editor in JavaScript. See https://github.com/marijnh/CodeMirror for the currently maintained version
http://codemirror.net/
Other
362 stars 63 forks source link

textarea inside wrapper gets focused first #27

Closed re5et closed 13 years ago

re5et commented 13 years ago

Directly inside the 'CodeMirror-wrapping' div is a textarea whose purpose i am not sure of. It comes just before the iframe and gets tab focused before the edit area. If possible it should be placed after the edit area, or better, the tabindex should be set very high since it is not used for anything visible. Possibly even betterer, It could also automatically send the focus to the edit area when focused.

marijnh commented 13 years ago

The textarea is used to intercept paste events. What kind of problem is it causing you, exactly? Just that tab ends up focusing it? I guess I could try hiding it when it it isn't being used.

re5et commented 13 years ago

its just a tab order annoyance. i have it in a form for users to submit snippets, and if you are tabbing through the form, it takes focus and cannot be seen, so it is a little weird for users. I think that just redirecting the focus event is probably wise. I added a little piece of code that does it for me after i make a new codemirror, have not experienced any ill effects.

out of curiosity how are you detecting "paste events"? I can paste into it using the context menu, but not with my normal paste method, most likely because i have emacs bindings in firefox. are you just checkout for ctrl+v or something?

marijnh commented 13 years ago

I've pushed a patch that adds the big tabIndex. Hiding and un-hiding the textarea caused weird issues, so I gave up on that.

As for paste-capturing... on browsers that produce proper paste events, we use those, on some browsers we don't mess with the paste event because pasting HTML doesn't cause problems, and on some browsers, we capture ctrl-v, and hope for the best. I've had similar issues with Firefox not pasting with emacs binding enabled, but I never figured out why that was -- regular paste should work, and on Firefox (at least pre-v4 versions) there is no 'paste' event, so CodeMirror shouldn't, in theory, interfere with a paste.

re5et commented 13 years ago

cool, thanks