【问题标题】:How do I make sure only one font and font size is used in a text field?如何确保在文本字段中仅使用一种字体和字体大小?
【发布时间】:2013-04-12 11:33:16
【问题描述】:

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

【问题讨论】:

    标签: textbox clipboard font-size livecode clipboard-interaction


    【解决方案1】:

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

    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 是什么意思?我只想插入剪贴板文本作为字段的插入点。
    • 没有更简单的解决办法是设置字段的属性吗?
    • 建议的解决方案不起作用。字段级别和卡片级别的 on pasteKey 处理程序都没有。
    • @BvG 确实说过它在 IDE 中不起作用,因为它会捕获并且不传递 pasteKey。如果您已经对粘贴的文本进行了格式化,那么您可以set the text of fld X to the text of fld X
    • 我已将set the text of me to the text of me 添加到 pasteKey 处理程序并将处理程序放在字段级别。现在从“开发”菜单中选择“暂停开发工具”时它可以工作了。
    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 2021-10-16
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    • 2018-02-20
    相关资源
    最近更新 更多