WebView changeFont: and changeColor: with no selection reset changes when i type

StackOverflow https://stackoverflow.com/questions/23214894

  •  07-07-2023
  •  | 
  •  

Вопрос

ok, the title is a bit confusing. I have a subclass of webview. i can type in it. now, if I change the font from the fontpanel, or the color from the colorpanel while having nothing selected, and then i type a character, this new character would be in the new font or the new color. if I change the font from a popupbutton, then set the selectedfont in the nsfontmanager, when i type a character, the font resets back to the font of the previous character.

is there a way to keep this "temporary" font or color change?

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

Решение 2

i finally figured it out. i looked at the source code of webkit to see what happens on changeFont: and changeColor:. it checks if you changed the font by converting two predefined fonts, and checking for common properties. so i subclassed nsfontmanager, and wrote a simple override for convertFont:, so webkit could understand that i did change the font, and it kept the "temporary" font.

Другие советы

I just looked at the Webview Class Reference docs and it doesn't seem like you can do that. You have to do it the first way, every time, to achieve what you want.

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