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

Editor shouldHandleKey not being called (again) #285

Open
easiwriter opened this issue Feb 25, 2024 · 3 comments
Open

Editor shouldHandleKey not being called (again) #285

easiwriter opened this issue Feb 25, 2024 · 3 comments

Comments

@easiwriter
Copy link

I've done more digging and discovered that Proton calls

func editor(_ editor: EditorView, shouldHandle key: EditorKey, modifierFlags: UIKeyModifierFlags, at range: NSRange, handled: inout Bool) { }

This does nothing, because it has not been overridden.

Whereas the documentation has this, which is what my code calls:

func editor(_ editor: EditorView, shouldHandle key: EditorKey, at range: NSRange, handled: inout Bool)

This possibly explains why Proton doesn't call it.

I added the modifierFlags to my call and it works, so it looks like there could either be a documentation error, or I didn't see it in the documentation.

@easiwriter
Copy link
Author

easiwriter commented Feb 25, 2024

Also shouldHandle is called twice in:

    static func editor(_ editor: EditorView, shouldHandle key: EditorKey, modifierFlags: UIKeyModifierFlags, at range: NSRange, handled: inout Bool) {
        editor.delegate?.editor(editor, shouldHandle: key, modifierFlags: modifierFlags, at: range, handled: &handled)
        editor.editorContextDelegate?.editor(editor, shouldHandle: key, modifierFlags: modifierFlags, at: range, handled: &handled)
    }

What is editorContextDelegate? Also handled isn't changed.

@rajdeep
Copy link
Owner

rajdeep commented Feb 29, 2024

@easiwriter, unfortunately the ReadMe is not updated for all the samples. I'd recommend using API Reference found here which I try to keep uptodate: https://rajdeep.github.io/proton/

in regards to EditorViewContext: basically you can create Attachments that contains EditorView in itself. Checkout Panel/Expand in CommandsExampleViewController to see an example. You can also read more about EditorViewContext here: https://rajdeep.github.io/proton/Classes/EditorViewContext.html

editorContextDelegate is the delegate that you can set on the context of the editor. If the delegate is set on Editor, the callbacks are received only for that editor. If the delegate is set on EditorViewContext instead, then the same callback will be received for all the Editors sharing the same context.

@easiwriter
Copy link
Author

easiwriter commented Feb 29, 2024 via email

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

No branches or pull requests

2 participants