SetSelectionRange
表單、互動、Unicode
描述
以所請求的索引單位設定作用中表單欄位編輯選取範圍的錨點與游標
兩個位置各自箝制,因此錨點大於游標會形成反向選取,而正規化的 SelectionStart 與 SelectionLength 屬性仍保持有序
碼點與字位叢集單位一律解析到有效的 Unicode 邊界,不會切開代理對、組合序列或接合的 emoji 叢集
宣告
function SetSelectionRange(AnchorIndex, CaretIndex: Integer;
IndexUnit: TPDFlibFormSelectionUnit): Integer;
參數
| AnchorIndex | 方向性選取範圍在 IndexUnit 中的固定端,限制到可編輯值內 |
|---|---|
| CaretIndex | 方向性選取範圍在 IndexUnit 中的移動端,限制到可編輯值內 |
| IndexUnit | fsuUTF16CodeUnit、fsuUnicodeCodePoint 或 fsuGraphemeCluster |
傳回值
編輯作用中且選取範圍已儲存時傳回 1,否則傳回 0
效能
碼位與字素邊界表會為目前的編輯值延遲建立、由後續選取作業重複使用,並在呼叫 SetEditValue 時失效
範例
if Session.BeginEdit(FieldIndex) = 1 then
begin
Session.SetEditValue('A' + WideChar($D83D) + WideChar($DE00) + 'B');
Session.SetSelectionRange(1, 2, fsuUnicodeCodePoint);
end;