NSSearchField confusion

Discussion in 'Mac Programming' started by ranguvar, Dec 11, 2009.

  1. ranguvar macrumors 6502

    Sep 18, 2009

    I'm drawing inside a custom NSSearchFieldCell subclass, but while the NSSearchField that the cell is in is active, the text gets drawn twice (once by my subclass and once somehow by the NSSearchField, I suppose).
    As soon as I unselect the NSSearchField, e.g. by clicking inside a table view, the text gets drawn correctly (only once, by the cell).

    A simple fix for this would of course be to let the cell only draw the text when the search field is inactive.
    I tried to implement this, but I got stuck:

    Is there nothing such as a - (BOOL)isSelected method for text fields or their cells?!

    There must surely be some way to check if a text field is selected by the user!
    Or do I miss a key concept of Cocoa?

    Thanks for any input, I'm totally lost.

  2. kainjow Moderator emeritus


    Jun 15, 2000
    Sounds like something in your drawing code isn't being done right. Maybe post some of it?

    The selected control is the firstResponder, so you can check for this via:
    if ([[control window] firstResponder] == control)
  3. ranguvar thread starter macrumors 6502

    Sep 18, 2009
    I had tried that, it didn't work though (dunno why). In the end, I used this method.

Share This Page