All,
I have a single column table which has a fixed width. I fetch data from a text file and display this in the table.
Sometimes the row data doesn’t fit in the set width, so the complete information is not visible. I don’t want to display a horizontal scroller. I want to display a tooltip when user clicks such a row. The tip will then display the complete data. I can access the row data, but I’m not able to show a tooltip when user clicks the row. Here is my code
on tableRowClicked()
if adataTable's selectedRow as integer is not equal to -1 then
set rowSel to (adataTable's selectedRow as integer)
set rowSel to (rowSel + 1)
set theRowData to item rowSel of theData
--theData is a list bound to the Array Controller (From Simple Table Example of shane's book)
end if
end tableRowClicked
on awakeFromNib()
-- some statements
adataTable's setAction_("tableRowClicked")
end awakeFromNib
Which method do I use to display a toltip when user click’s the row? I tried using setToolTip method and got an error.
[NSTextFieldCell setToolTip:]: unrecognized selector sent to instance 0x400da2d00
a tooltip is supposed to be displayed when the user pauses the mouse a few seconds on an UI element.
To manage tooltips in a table view implement tableView_toolTipForCell_rect_tableColumn_row_mouseLocation_()
Stefan,
So I have the following properties declared in my code
property theDatacell : missing value --- Hooked to the data Cell
property theDataCol : missing value --- Hooked to the data Column
on tableRowClicked()
if adataTable's selectedRow as integer is not equal to -1 then
set rowSel to (adataTable's selectedRow as integer)
set rowSel to (rowSel + 1)
set theRowData to item rowSel of theData
--theData is a list bound to the Array Controller (From Simple Table Example of shane's book)
tableView_toolTipForCell_rect_tableColumn_row_mouseLocation_(adataTable,theDatacell, rect,theDataCol,rowSel, mouseLocation)
end if
end tableRowClicked
How do I pass the values rect and mouseLocation to this function ? It seems to be a struct data type from Xcode docs.
Shane,
Looks like the theDatacell property is actually a NSTextFieldCell object and the method requires a NSCell object. I can’t seem to find the NSCell Object to hook the theDatacell property
I think you’re misunderstanding – tableView_toolTipForCell_rect_tableColumn_row_mouseLocation_ is a method you have to implement as a handler in the table’s delegate. The values are passed to you, and you have to return a suitable string.
But looking at the docs, rect is an NSRectPointer, and I don’t think you will be able to handle that in ASObjC anyway. So it may all be moot.
I’m still not sure of your problem. You say you have a single-column table; you should be getting the tooltip automatically when you hover over an overset cell. That’s how tooltips are supposed to work – by hovering, not selecting.
I have a single-column table whose rows are populated using data from a text file. Since the row data tends to get clipped coz of the set width, I want the row value as the tool tip. When I hover over a row(or cell ) I don’t see any tool tip. I thought I had to programmatically set the tooltip.