Browse Source

fix dublicates in MacOS special character inputs

pull/21569/head
Anastassia Pellja 4 months ago
parent
commit
08d3e69557
  1. 45
      native/Avalonia.Native/src/OSX/AvnView.mm

45
native/Avalonia.Native/src/OSX/AvnView.mm

@ -830,7 +830,50 @@ static void ConvertTilt(NSPoint tilt, float* xTilt, float* yTilt)
{ {
text = (NSString*) string; text = (NSString*) string;
} }
// If replacement range is provided for committed text input,
// select the corresponding surrounding text
// Skip this when marked text is active.
if (replacementRange.location != NSNotFound &&
![self hasMarkedText] &&
parent->InputMethod->IsActive())
{
int start;
int end;
if (replacementRange.length > 0)
{
if (_selectedRange.length > 0)
{
start = (int)replacementRange.location;
end = (int)(replacementRange.location + replacementRange.length);
}
// ReplacementRange is reported one position behind,
// so adjust it.
else
{
start = (int)replacementRange.location + 1;
end = (int)(replacementRange.location + replacementRange.length) + 1;
}
}
// Special case for the first character. ReplacementRange for the first character
// arrives as {0,0} instead of a replacement range, so explicitly
// select it.
else if (replacementRange.location == 0)
{
start = 0;
end = 1;
}
else
{
return;
}
parent->InputMethod->Client->SelectInSurroundingText(start, end);
}
[self unmarkText]; [self unmarkText];
uint64_t timestamp = static_cast<uint64_t>([NSDate timeIntervalSinceReferenceDate] * 1000); uint64_t timestamp = static_cast<uint64_t>([NSDate timeIntervalSinceReferenceDate] * 1000);

Loading…
Cancel
Save