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 #277

Closed
easiwriter opened this issue Feb 17, 2024 · 7 comments
Closed

Editor shouldHandleKey not being called #277

easiwriter opened this issue Feb 17, 2024 · 7 comments

Comments

@easiwriter
Copy link

easiwriter commented Feb 17, 2024

in the following code in RichTextEditorContext:

if text == "\n" {
           richTextView.richTextViewDelegate?.richTextView(richTextView, shouldHandle: .enter, modifierFlags: [], at: range, handled: &handled)

           guard handled == false else {
               return false
           }
           richTextView.richTextViewDelegate?.richTextView(richTextView, didReceive: .enter, modifierFlags: [], at: range)
       }

My shouldHandle method is not being called whereas the didReceive method is called. My code contains:

        func editor(_ editor: EditorView, didReceiveKey key: EditorKey, at range: NSRange) {
            if key == .enter {
                enterCount += 1
            }
        }

        func editor(_ editor: EditorView, shouldHandle key: EditorKey, at range: NSRange, handled: inout Bool) {
            if key == .enter {
                enterCount += 1
            }
        }

I haven't worked on this for a long time and when I last did I'm sure shouldHandle was called (I just added didReceiveKey to see if that was being called).

Have you changed this?

@rajdeep
Copy link
Owner

rajdeep commented Feb 19, 2024

This callback internally maps to:

func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool 

and I have verified this to confirm that it is working as expected. The callback is bubbled up via EditorViewDelegate from editor.delegate or editor.context.delegate. Are you sure you have at least one of this set correctly?

@easiwriter
Copy link
Author

easiwriter commented Feb 19, 2024 via email

@rajdeep
Copy link
Owner

rajdeep commented Feb 21, 2024

Well, you have been developing software for more than the days I have seen in my life :) I really wish I could be more useful. For now, I am closing this issue. If you ever feel like getting back, and still have something that I could help with, I'll be more than happy to.

All the very best.

@rajdeep rajdeep closed this as completed Feb 21, 2024
@easiwriter
Copy link
Author

easiwriter commented Feb 28, 2024 via email

@rajdeep
Copy link
Owner

rajdeep commented Feb 28, 2024

Happy to see you again 🙂. I'll try to get back to you by tomorrow on the issues you've raised today and earlier.

On a side note, I'd be interested to see your app and how you've been using Proton. Any thing you can link here for me to see?

@easiwriter
Copy link
Author

easiwriter commented Feb 28, 2024 via email

@rajdeep
Copy link
Owner

rajdeep commented Mar 5, 2024

@easiwriter, you may use vicky_ice @ yahoo.com for TestFlight invite. Thank you.

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