Skip to content

Conversation

onflapp
Copy link
Contributor

@onflapp onflapp commented Sep 17, 2022

the existing implementation of doubleClickedOnCell will not be called because the click count is likely to more more than 2 by that point. I suspect it has to do with double click being interpreted as select word first.

I propose to change the condition to work after 2 or more clicks to make it more robust.

@fredkiefer
Copy link
Member

The change itself looks fine, could you please remove the unrelated change from the other merge request so that this could be merged?

@onflapp
Copy link
Contributor Author

onflapp commented Oct 16, 2022

The change itself looks fine, could you please remove the unrelated change from the other merge request so that this could be merged?

OK, done

@fredkiefer
Copy link
Member

In the meantime Riccardo set up another pull request #160 and claims that this might resolve your issues as well. I am unsure and your code looks fine to me. Could you please give his changes a try and report back?

@onflapp
Copy link
Contributor Author

onflapp commented Oct 19, 2022

In the meantime Riccardo set up another pull request #160 and claims that this might resolve your issues as well. I am unsure and your code looks fine to me. Could you please give his changes a try and report back?

No, my problem is still there. For example: TextEdit fork with support for attachments (https://github.com/onflapp/gs-textedit). The delegate will simply not be called because 2 clicks will select text instead.

Interestingly enough, Cocoa doesn't do that. Clicks on attachments are not handled as selection at all - I guess they are being tracked separately. But this might be very recent change because I do vaguely remember that attachments were handled as special characters in the past.

My suggesting would be to go ahead with this change as it has minimal impact on anything else and it fixes problem that would normally have to be fixed or worked around in the application code.

@rmottola
Copy link
Member

As far as I could test with clicks on cocoa regarding attachments and GNUmail, a single click is correct to invoke the delegate for the save action, multiple click make a select, since it is a character that can be selected, after all. On GNUstep we had an issue with attachment finding depending on the click position, I fixed that.

I am somehow unsure that a "multiple click" should be handled like a double-click, it would be like eating other clicks away.

@onflapp
Copy link
Contributor Author

onflapp commented Oct 25, 2022

I don't dispute that GNUmail is working correctly.
What doesn't work is "textView:doubleClickedOnCell:inRect:atIndex:"
https://developer.apple.com/documentation/appkit/nstextviewdelegate/1449333-textview?language=objc

The delegate is not called.

@gcasa gcasa requested a review from Copilot September 17, 2025 06:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a double-click handling issue in NSTextAttachment by making the click count condition more robust. The existing implementation only triggers on exactly 2 clicks, but the click count may exceed 2 due to text selection behavior interfering with the event handling.

  • Changed click count condition from == 2 to >= 2 for more reliable double-click detection
  • Applied the fix to both NSLeftMouseUp and NSLeftMouseDown event handling paths

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gcasa
Copy link
Member

gcasa commented Sep 17, 2025

Do you think this PR is worth merging? I can see how someone might click multiple times.

@rmottola
Copy link
Member

Last word to @fredkiefer . I think it is a bad PR, since it removes a safety measure in the click number. What if there is an error? I remember seeing that code when debugging this stuff with Fred and he argumented it that way and I agree.
We don't handle "triple clicks" or more and if for some error it happens, this is safer.

@gcasa
Copy link
Member

gcasa commented Sep 18, 2025

Last word to @fredkiefer . I think it is a bad PR, since it removes a safety measure in the click number. What if there is an error? I remember seeing that code when debugging this stuff with Fred and he argumented it that way and I agree.

We don't handle "triple clicks" or more and if for some error it happens, this is safer.

Agreed. I've thought about it and it seems clumsy. Given that no decision has been made on this in months I am tempted to close it as I really despise PRs remaining open for inordinate amounts of time.

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

Successfully merging this pull request may close these issues.

4 participants