Merge pull request #160 from gnustep/AttachmentIndexFix

Fix click on TextAttachmentCells, where the left side was not respected.
This commit is contained in:
Fred Kiefer 2022-10-25 23:06:47 +02:00 committed by GitHub
commit 59558a519d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2022-10-11 Riccardo Mottola <rm@gnu.org>
* Source/NSTextView.m
Fix click on TextAttachmentCells, where the left side was not respected.
This was because index was respecting fraction and thus loosing the
attachment when clicking on the right part, only for this case,
recalculate character index without respectFraction.
2022-09-01 Gregory John Casamento <greg.casamento@gmail.com>
* Source/NSButtonCell.m: Move method to detect if button is a

View file

@ -5554,12 +5554,18 @@ other than copy/paste or dragging. */
if (granularity == NSSelectByCharacter)
{
NSTextAttachment *attachment;
NSInteger startIndexNoFraction;
/* since we look for an attachment with by-character granularity,
recalculate the index without resepecting fraction */
startIndexNoFraction = [self _characterIndexForPoint: startPoint
respectFraction: NO];
/* Check if the click was on an attachment cell. */
attachment = [_textStorage attribute: NSAttachmentAttributeName
atIndex: startIndex
atIndex: startIndexNoFraction
effectiveRange: NULL];
if (attachment != nil)
{
id <NSTextAttachmentCell> cell = [attachment attachmentCell];
@ -5594,11 +5600,11 @@ other than copy/paste or dragging. */
if ([cell wantsToTrackMouseForEvent: theEvent
inRect: cellFrame
ofView: self
atCharacterIndex: startIndex]
atCharacterIndex: startIndexNoFraction]
&& [cell trackMouse: theEvent
inRect: cellFrame
ofView: self
atCharacterIndex: startIndex
atCharacterIndex: startIndexNoFraction
untilMouseUp: NO])
{
return;