Вопрос

The default settings of a text field allow content of a different font and font size to be pasted into the field. How do I make sure that pasted content is converted to use a specific font and font size, i.e. the one I choose as default for the field?

Это было полезно?

Решение

You need to trap the paste from happening, then replicate it yourself. For example in a field (untested):

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

You also need to care about drag & drop:

on dragDrop
  put the dragData["text"] into char (word 2 of the dropChunk) to (word 4 of the dropChunk) of me
end dragDrop

If you use the "paste" command, it will not trigger the pasteKey message, so if you have such code in your app, so you need to make sure to handle special cases there.

Note: Testing this in the IDE can be tricky, because it interrupts some messages, including pasteKey (use "suspend development tools" from the "development" menu).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top