A color well in a table view?

  • In my Mac app I have a table view which so far only displays text and numbers. Now I'd like to put color wells in one column (to supply colors for the lines in the diagram) and checkboxes in another (to decide whether each line should be drawn or not). Can I do that? If so, what's the best way to do that? Is it as easy as modifying tableview:objectvaluefortablecolumn:row: to retrieve the color wells from the array and return them to the table view, or are there some hoops I have to jump through?

    Thanks in advance.

    Sent from my iPad
  • On Thu, 7 Jun 2012 13:53:49 +0100, H. Miersch said:

    > In my Mac app I have a table view which so far only displays text and
    > numbers. Now I'd like to put color wells in one column (to supply colors
    > for the lines in the diagram) and checkboxes in another (to decide
    > whether each line should be drawn or not). Can I do that? If so, what's
    > the best way to do that? Is it as easy as modifying
    > tableview:objectvaluefortablecolumn:row: to retrieve the color wells
    > from the array and return them to the table view, or are there some
    > hoops I have to jump through?

    Unlike most NSControls, there is no NSCell for NSColorWell.  But 10.7 did add view-based tableviews, so if you can require 10.7+, that's probably your best bet.  I've been meaning to try it myself...

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • On Jun 7, 2012, at 8:32 AM, Sean McBride <sean...> wrote:

    > On Thu, 7 Jun 2012 13:53:49 +0100, H. Miersch said:
    >
    >> In my Mac app I have a table view which so far only displays text and
    >> numbers. Now I'd like to put color wells in one column (to supply colors
    >> for the lines in the diagram) and checkboxes in another (to decide
    >> whether each line should be drawn or not). Can I do that? If so, what's
    >> the best way to do that? Is it as easy as modifying
    >> tableview:objectvaluefortablecolumn:row: to retrieve the color wells
    >> from the array and return them to the table view, or are there some
    >> hoops I have to jump through?
    >
    > Unlike most NSControls, there is no NSCell for NSColorWell.  But 10.7 did add view-based tableviews, so if you can require 10.7+, that's probably your best bet.  I've been meaning to try it myself...

    I've given it a try and it works great!

    Alternatively,  you can implement a custom cell; This demo does just that:

    http://developer.apple.com/library/mac/#samplecode/AnimatedTableView/Introd
    uction/Intro.html


    corbin
  • I found the switch that makes my table view view-based, but then my table view showed some default text instead of the text I return from -tableview:objectvaluefortablecolumn:row:
    What can I do about that?

    Sent from my iPhone

    On 7 Jun 2012, at 16:32, Sean McBride <sean...> wrote:

    > On Thu, 7 Jun 2012 13:53:49 +0100, H. Miersch said:
    >
    >> In my Mac app I have a table view which so far only displays text and
    >> numbers. Now I'd like to put color wells in one column (to supply colors
    >> for the lines in the diagram) and checkboxes in another (to decide
    >> whether each line should be drawn or not). Can I do that? If so, what's
    >> the best way to do that? Is it as easy as modifying
    >> tableview:objectvaluefortablecolumn:row: to retrieve the color wells
    >> from the array and return them to the table view, or are there some
    >> hoops I have to jump through?
    >
    > Unlike most NSControls, there is no NSCell for NSColorWell.  But 10.7 did add view-based tableviews, so if you can require 10.7+, that's probably your best bet.  I've been meaning to try it myself...
    >
    > --
    > ____________________________________________________________
    > Sean McBride, B. Eng                <sean...>
    > Rogue Research                        www.rogue-research.com
    > Mac Software Developer              Montréal, Québec, Canada
    >
    >
  • On Jun 11, 2012, at 8:45 AM, H Miersch <hmiersch...> wrote:

    > I found the switch that makes my table view view-based, but then my table view showed some default text instead of the text I return from -tableview:objectvaluefortablecolumn:row:
    > What can I do about that?

    I recommend reading the documentation on how to use a View Based NSTableView, and/or look at the TAbleViewPlayround demo to see how it is done.

    corbin

    >
    > Sent from my iPhone
    >
    > On 7 Jun 2012, at 16:32, Sean McBride <sean...> wrote:
    >
    >> On Thu, 7 Jun 2012 13:53:49 +0100, H. Miersch said:
    >>
    >>> In my Mac app I have a table view which so far only displays text and
    >>> numbers. Now I'd like to put color wells in one column (to supply colors
    >>> for the lines in the diagram) and checkboxes in another (to decide
    >>> whether each line should be drawn or not). Can I do that? If so, what's
    >>> the best way to do that? Is it as easy as modifying
    >>> tableview:objectvaluefortablecolumn:row: to retrieve the color wells
    >>> from the array and return them to the table view, or are there some
    >>> hoops I have to jump through?
    >>
    >> Unlike most NSControls, there is no NSCell for NSColorWell.  But 10.7 did add view-based tableviews, so if you can require 10.7+, that's probably your best bet.  I've been meaning to try it myself...
    >>
    >> --
  • Not sure if this would be helpful, but maybe a custom NSCell subclass that acts like a color well?

    On Jun 7, 2012, at 10:32 AM, Sean McBride wrote:

    > On Thu, 7 Jun 2012 13:53:49 +0100, H. Miersch said:
    >
    >> In my Mac app I have a table view which so far only displays text and
    >> numbers. Now I'd like to put color wells in one column (to supply colors
    >> for the lines in the diagram) and checkboxes in another (to decide
    >> whether each line should be drawn or not). Can I do that? If so, what's
    >> the best way to do that? Is it as easy as modifying
    >> tableview:objectvaluefortablecolumn:row: to retrieve the color wells
    >> from the array and return them to the table view, or are there some
    >> hoops I have to jump through?
    >
    > Unlike most NSControls, there is no NSCell for NSColorWell.  But 10.7 did add view-based tableviews, so if you can require 10.7+, that's probably your best bet.  I've been meaning to try it myself...
    >
    > --
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today