mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
TextInputTarget: Add underlining support for composing regions on macOS and iOS
This commit is contained in:
parent
f3b7b4ca2e
commit
1f1d657260
2 changed files with 10 additions and 0 deletions
|
|
@ -454,6 +454,8 @@ public:
|
|||
target->setHighlightedRegion (getMarkedTextRange());
|
||||
|
||||
target->insertTextAtCaret (text);
|
||||
target->setTemporaryUnderlining ({ Range<int>::withStartAndLength (startOfMarkedTextInTextInputTarget,
|
||||
text.length()) });
|
||||
stringBeingComposed = text;
|
||||
}
|
||||
|
||||
|
|
@ -1179,6 +1181,8 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet<UIPress*>* presses, UIPr
|
|||
redirectKeyPresses ('\t');
|
||||
else
|
||||
owner->replaceMarkedRangeWithText (target, nsStringToJuce (text));
|
||||
|
||||
target->setTemporaryUnderlining ({});
|
||||
}
|
||||
|
||||
owner->stringBeingComposed.clear();
|
||||
|
|
@ -1260,6 +1264,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet<UIPress*>* presses, UIPr
|
|||
return;
|
||||
|
||||
owner->replaceMarkedRangeWithText (target, owner->stringBeingComposed);
|
||||
target->setTemporaryUnderlining ({});
|
||||
owner->stringBeingComposed.clear();
|
||||
owner->startOfMarkedTextInTextInputTarget = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2121,6 +2121,7 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper<ObjCClass<NSView>>
|
|||
}());
|
||||
|
||||
target->insertTextAtCaret (newText);
|
||||
target->setTemporaryUnderlining ({});
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -2206,6 +2207,7 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper<ObjCClass<NSView>>
|
|||
|
||||
target->setHighlightedRegion (initialHighlight);
|
||||
target->insertTextAtCaret (marked);
|
||||
target->setTemporaryUnderlining ({ Range<int>::withStartAndLength (initialHighlight.getStart(), marked.length()) });
|
||||
target->setHighlightedRegion (finalHighlight + owner->startOfMarkedTextInTextInputTarget);
|
||||
}
|
||||
}
|
||||
|
|
@ -2218,7 +2220,10 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper<ObjCClass<NSView>>
|
|||
if (owner->stringBeingComposed.isNotEmpty())
|
||||
{
|
||||
if (auto* target = owner->findCurrentTextInputTarget())
|
||||
{
|
||||
target->insertTextAtCaret (owner->stringBeingComposed);
|
||||
target->setTemporaryUnderlining ({});
|
||||
}
|
||||
|
||||
owner->stringBeingComposed.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue