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

Ace editor grabs too many keys #534

Open
edreamleo opened this issue Nov 30, 2018 · 3 comments
Open

Ace editor grabs too many keys #534

edreamleo opened this issue Nov 30, 2018 · 3 comments

Comments

@edreamleo
Copy link

edreamleo commented Nov 30, 2018

The code in flexx issue #312 does not work in a flx.Widget that wraps an ace editor, as shown in the ace editor example. True, this is not really a flexx issue, but any words of wisdom would be appreciated.

Here is the present emitter for the body pane:

# **Does** fire for most plain keys and control keys.
# Does **not** fire for Ctrl-A, Ctrl-F, tab or backspace.

@flx.emitter
def key_press(self, e):
    ev = self._create_key_event(e)
    f_key = not ev['modifiers'] and ev['key'].startswith('F')
    print('BODY: key_press', repr(ev), 'preventDefault', not f_key)
    if not f_key:
        e.preventDefault()
    return ev

This is a serious problem for LeoWapp. I shall investigate what CodeMirror does.

Actually, this (over?) simplified emitter exhibits the same behavior:

@flx.emitter
def key_press(self, e):
    ev = self._create_key_event(e)
    e.preventDefault()
    return ev
@Korijn
Copy link

Korijn commented Nov 30, 2018

I believe you'll have to look up the specifics of the browser runtime you're using in this case.

@edreamleo
Copy link
Author

@Korijn Thanks for your helpful comment. As a newbie, I was unaware of browser differences.

@almarklein
Copy link
Member

I suspect that the editors will also consume (i.e. call e.preventDefault()) certain events. Tab is a good example. The editor need to consume that event, or the browser will see the tab key and change focus to the next tabbable element.

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

No branches or pull requests

3 participants