0

文本字段的默认设置允许将不同字体和字体大小的内容粘贴到该字段中。如何确保将粘贴的内容转换为使用特定字体和字体大小,即我选择作为该字段的默认字体?

4

1 回答 1

2

您需要阻止粘贴发生,然后自己复制它。例如在一个领域(未经测试):

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(使用“开发”菜单中的“暂停开发工具”)。

于 2013-04-19T10:11:18.030 回答