Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTextView overlay causes oddities with first responder status
    primarykey
    data
    text
    <p>I have an <code>NSTextView</code> in an <code>NSScrollView</code>, and I am programmatically inserting an <code>NSView</code> subclass as a subview of the <code>NSTextView</code>. This <code>NSView</code> acts as an overlay, superimposing graphical information about the text beneath it.</p> <p>I thought it was working quite well until I noticed that the text view does not respond to right clicks. Other operations (editing, selection) seem to work just fine. </p> <p>Also, if the first responder is changed to a sibling of the scroll view (an outline view, for example) the text view does not regain first responder status from clicking on it. The selection will change in response to clicking, but the selection highlight is gray instead of blue (indicating that the text view is not the first responder).</p> <p>If I offset the frame of the overlay subview, the text view behaves 100% normally in the area not overlapped by the overlay, but the overlapped area behaves incorrectly, as outlined above.</p> <p><strong>Steps To Replicate This Behavior on Mac OS X 10.6.4:</strong></p> <ol> <li>Create a plain old non-document-based Cocoa app.</li> <li>Add an `NSTextView' IBOutlet to the app delegate .h.</li> <li>Add an <code>NSTextView</code> to the window in MainMenu.xib. Connect the textView outlet.</li> <li>Type in a bit of code:</li> </ol> <p>In <code>applicationDidFinishLaunching:</code></p> <pre><code>NSView *overlay = [[NSView alloc] initWithFrame:textView.bounds]; [textView addSubview:overlay]; [overlay release]; </code></pre> <p>Run the app, observe that right click in the text area does not work as it should, yet you can still otherwise interact with the text view.</p> <p>Next, add an NSOutlineView to the window in the xib. Observe that once focus leaves the text area (if you click on the outline view) with the overlay in place, you cannot set the focus back to the text view (it will not become first responder again).</p> <hr> <p>Is there some way I can enable the <code>NSTextView</code> to receive all of its events, even though my <code>NSView</code> overlay does not accept first responder or mouse events? I suspect this might be related to the field editor – perhaps it is ignoring events it thinks are destined to the overlay view?</p>
    singulars
    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