【发布时间】:2013-04-12 11:33:16
【问题描述】:
文本字段的默认设置允许将不同字体和字体大小的内容粘贴到该字段中。如何确保将粘贴的内容转换为使用特定字体和字体大小,即我为该字段选择的默认字体?
【问题讨论】:
标签: textbox clipboard font-size livecode clipboard-interaction
文本字段的默认设置允许将不同字体和字体大小的内容粘贴到该字段中。如何确保将粘贴的内容转换为使用特定字体和字体大小,即我为该字段选择的默认字体?
【问题讨论】:
标签: textbox clipboard font-size livecode clipboard-interaction
您需要阻止粘贴发生,然后自己复制它。例如在一个字段中(未测试):
on pasteKey
put the clipBoardData["text"] into char (word 2 of the selectedchunk of me) to (word 4 of the selectedchunk of me) of me
end pasteKey
你还需要关心拖放:
on dragDrop
put the dragData["text"] into char (word 2 of the dropChunk) to (word 4 of the dropChunk) of me
end dragDrop
如果你使用“粘贴”命令,它不会触发 pasteKey 消息,所以如果你的应用中有这样的代码,那么你需要确保在那里处理特殊情况。
注意:在 IDE 中进行测试可能会很棘手,因为它会中断一些消息,包括 pasteKey(使用“开发”菜单中的“暂停开发工具”)。
【讨论】:
(word 2 of the selectedchunk of me) to (word 4 of the selectedchunk of me) of me 是什么意思?我只想插入剪贴板文本作为字段的插入点。
set the text of fld X to the text of fld X
set the text of me to the text of me 添加到 pasteKey 处理程序并将处理程序放在字段级别。现在从“开发”菜单中选择“暂停开发工具”时它可以工作了。