• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using NSComboBoxCells within NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSComboBoxCells within NSTableView


  • Subject: Using NSComboBoxCells within NSTableView
  • From: Evan Coyne Maloney <email@hidden>
  • Date: Thu, 17 Jan 2002 14:38:49 -0500

I'm working on an application where I want to present multiple rows containing three combo boxes in each row. In order to line up the combo boxes (and allow resizing, etc.), I'm placing the combo boxes into an NSTableView.

The combo boxes show up properly in the NSTableView, but they do not respond normally to mouse clicks. What I want is to be able to edit the text in the combo box, whereby a single mouse click would place the text cursor in the combo box and allow the user to edit. I had assumed I would get this behavior by default.

Because NSTableView processes mouseDown: messages in order to select the cell, I thought maybe the mouseDown: message was getting "trapped" by NSTableView and not getting passed to the appropriate NSComboBoxCell. However, I later noticed that clicking on the down arrow of the combo box works, but that's the only part of the combo box that behaves properly.

Am I missing something simple? Or do I need to trap the mouseDown: messages and somehow redirect them to the NSComboBoxCells?

(If it is the latter, I don't think there's anything I can do. Given a mouseDown: in an NSTableView, I am able to convert the point of the mouseDown: event into the coordinates of the NSTableView, and use that point to get the row and column index in the table, but there doesn't seem to be a way to use those indices to get the cell itself. Does anyone know how to get a handle to a cell from an NSTableView given row and column indices?)

Background information:

I am causing the NSTableView to use NSComboBoxCells within the columns by setting the cell class for each column from within the awakeFromNib method of the table's controller. The relevant code is:

NSComboBoxCell* cell = nil;
cell = [[NSComboBoxCell alloc] init];
[cell setControlSize:NSSmallControlSize];
[cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
[[m_parseTable tableColumnWithIdentifier:COLID_TAGNAME] setDataCell:cell];
[[m_parseTable tableColumnWithIdentifier:COLID_STARTDELIM] setDataCell:
cell];
[[m_parseTable tableColumnWithIdentifier:COLID_ENDDELIM] setDataCell:cell];
[cell release];

As you can see, my assumption is that the cell is retained by the setDataCell: method. It doesn't crash, so this seems correct.

Evan Coyne Maloney____________________________________________________
The six-legged fire-breathing dog email@hidden


  • Prev by Date: Inheritance problem...
  • Next by Date: Re: Archiving three arrays
  • Previous by thread: Re: Inheritance problem...
  • Next by thread: NSTableView truncate text
  • Index(es):
    • Date
    • Thread