NSTableview tooltip bug?

  • I have an NSTableview column where each cell contains a file name. I use tooltips (addToolTipRect and NSToolTipOwner protocol)  to show the complete path to the file when the user hovers the mouse over the cell. This works fine unless the name of the file exceeds the column width - 3 pixels. i.e. if the width of the text for the cell is greater than (column width - 3) I get a strange behaviour: the correct tooltip flashes briefly in the usual place relative to the cell, then the cell itself becomes highlighted with a bright yellow background. If the text width is greater than the cell width the the highlighted rectangle extends over the column boundary, so I guess it is the enclosing rectangle of the cell's text that is highlighted.

    I created a category on NSString to define a truncated string method where I remove characters from the middle of the string to fit it into a specified width. My workaround to this problem was to specify the column width - 3 as the width I wanted for the truncated string.

    Has anyone else seen this? Is it a known bug?

    Thanks, Don

    ------------
    Don Hall
    Apps & More Software Design, Inc.
    <don...>
  • hi don,
    I recommend using the builtin tooltip support in NSTableView. There is a delegate method to provide the tool tip. Next, you are seeing expansionToolTips. Look at NSCell.h for custom drawing API for them. Or, turn them off for your table with API on NSTableView.

    corbin

    On May 1, 2012, at 5:10 PM, Donald Hall <don...> wrote:

    > I have an NSTableview column where each cell contains a file name. I use tooltips (addToolTipRect and NSToolTipOwner protocol)  to show the complete path to the file when the user hovers the mouse over the cell. This works fine unless the name of the file exceeds the column width - 3 pixels. i.e. if the width of the text for the cell is greater than (column width - 3) I get a strange behaviour: the correct tooltip flashes briefly in the usual place relative to the cell, then the cell itself becomes highlighted with a bright yellow background. If the text width is greater than the cell width the the highlighted rectangle extends over the column boundary, so I guess it is the enclosing rectangle of the cell's text that is highlighted.
    >
    > I created a category on NSString to define a truncated string method where I remove characters from the middle of the string to fit it into a specified width. My workaround to this problem was to specify the column width - 3 as the width I wanted for the truncated string.
    >
    > Has anyone else seen this? Is it a known bug?
    >
    > Thanks, Don
    >
    > ------------
    > Don Hall
    > Apps & More Software Design, Inc.
    > <don...>
  • Thanks! Got it running in a few minutes. For others, I used the NSTableViewDelegate methods

    tableView:toolTipForCell:rect:tableColumn:row:mouseLocation:

    and

    tableView:shouldShowCellExpansionForTableColumn:row:

    to prevent the cell expansion.
    ------------
    Don Hall
    Apps & More Software Design, Inc.
    <don...>

    On 2012-05-02, at 11:54 AM, <cocoa-dev-request...> wrote:

    > From: Corbin Dunn <corbind...>
    > To: Donald Hall <don...>
    > Cc: <cocoa-dev...>
    > Subject: Re: NSTableview tooltip bug?
    > Message-ID: <0A0B2CDE-D218-4D90-8021-C73872AFD527...>
    > Content-Type: text/plain; charset=us-ascii
    >
    > hi don,
    > I recommend using the builtin tooltip support in NSTableView. There is a delegate method to provide the tool tip. Next, you are seeing expansionToolTips. Look at NSCell.h for custom drawing API for them. Or, turn them off for your table with API on NSTableView.
    >
    > corbin
    >
    > On May 1, 2012, at 5:10 PM, Donald Hall <don...> wrote:
    >
    >> I have an NSTableview column where each cell contains a file name. I use tooltips (addToolTipRect and NSToolTipOwner protocol)  to show the complete path to the file when the user hovers the mouse over the cell. This works fine unless the name of the file exceeds the column width - 3 pixels. i.e. if the width of the text for the cell is greater than (column width - 3) I get a strange behaviour: the correct tooltip flashes briefly in the usual place relative to the cell, then the cell itself becomes highlighted with a bright yellow background. If the text width is greater than the cell width the the highlighted rectangle extends over the column boundary, so I guess it is the enclosing rectangle of the cell's text that is highlighted.
    >>
    >> I created a category on NSString to define a truncated string method where I remove characters from the middle of the string to fit it into a specified width. My workaround to this problem was to specify the column width - 3 as the width I wanted for the truncated string.
    >>
    >> Has anyone else seen this? Is it a known bug?
    >>
    >> Thanks, Don
    >>
    >> ------------
    >> Don Hall
    >> Apps & More Software Design, Inc.
    >> <don...>
    >>
    >
previous month may 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 31      
Go to today