Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I react meaningfully to a changeAttributes: delegation pass-through from WebView?
    primarykey
    data
    text
    <p><code>WebView</code> supports, through the <code>WebEditingDelegate</code>, a mechanism for the delegate to implement custom behavior for a variety of actions the <code>WebView</code> (or the private <code>WebHTMLView</code>) receives. When an action such as:</p> <pre><code>-(void)changeAttributes:(id)sender </code></pre> <p>is received in <code>WebHTMLView</code>, it is passed through to the delegate method:</p> <pre><code>-(BOOL)webView:(WebView *)webView doCommandBySelector:(SEL)command </code></pre> <p>Unfortunately, the mechanism does not provide for conveyance of the "<code>sender</code>" in the original action method.</p> <p>For the vast majority of actions, the sender is unimportant, but for changeAttributes, and changeFont, for example, the contract requires that "<code>sender</code>" be called by the recipient in order to e.g. <code>convertAttributes:</code> or <code>convertFont:</code>.</p> <p>For the <code>changeFont</code> case, it turns out that calling <code>[[NSFontManager sharedFontManager] convertFont:]</code> is sufficient, as coincidentally this is what the sender is.</p> <p>In the <code>changeAttributes</code> case, in particular when strikethrough is changed, the sender may be a private class "<code>NSFontEffectsBox</code>" which presumably corresponds to the subsection of the font panel that is responsible for changing strikethrough/etc settings.</p> <p>Unfortunately, calling <code>[[NSFontManager sharedFontManager] convertAttributes:]</code> does NOT obtain the expected attribute changes. This leaves a delegate who is interested in implementing this method meaningfully in a bit of a conundrum:</p> <ol> <li><p>WebKit does not convey the sender, so the delegate can't make the contractual <code>[sender convertAttributes:]</code> call.</p></li> <li><p>The <code>changeAttributes:</code> call is sent to a private WebKit class, <code>WebHTMLView</code>, which cannot be subclassed to, e.g., customize the behavior of <code>changeAttributes:</code>.</p></li> <li><p>The sender for the <code>changeAttributes:</code> call, <code>NSFontEffectsBox</code>, is a private class and cannot be accessed e.g. as <code>[NSFontEffectsBox sharedFontEffectsBox]</code>.</p></li> </ol> <p>In short: there appears to be no way for a developer to meaningfully override the behavior of <code>changeAttributes:</code> for a <code>WebView</code>.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload