Two different table views cover the same area. Via a popup button the user toogles between them.
I did that:
property parent : class "NSObject"
property TableView1 : missing value
property TableView2 : missing value
-- IB Outlets
property popupButton : missing value
-- IB Actions (button clicks)
on chooseTableView_(sender)
set choose to (popupButton's titleOfSelectedItem) as string
set headerView1 to TableView1's headerView
set headerView2 to TableView2's headerView
log headerView2 -- <NSTableHeaderView: 0x20078c7a0>
if choose is "Table View 1" then
TableView1's setHidden_(false)
TableView2's setHidden_(true)
headerView1's setHidden_(false)
headerView2's setHidden_(true)
else if choose is "Table View 2" then
TableView1's setHidden_(true)
TableView2's setHidden_(false)
headerView1's setHidden_(true)
headerView2's setHidden_(false)
end if
end chooseTableView_
The result:
The tables toggle correctly; but the header don’t.
The header view of the table set in IB foremost is to be seen and the other table has an empty header area.
your advise to do it with ‘views’ makes me confusing. In the documentation I have not found how to get the view of a table view. There is a scroll view of course, but I don’t know how to get an access to it.
On the bindings panel of a scroll view I have found a possibility to do something with ‘Hidden’. But that’s all.
I got a solution (perhaps not the best one, but it works).
property parent : class "NSObject"
property mainWindow : missing value
property theContentView : missing value
property scrollView1 : missing value
property scrollView2 : missing value
-- IB Outlets
property popupButton : missing value
-- IB Actions (button clicks)
on chooseTableView_(sender)
set choose to (popupButton's titleOfSelectedItem) as string
set theContentView to mainWindow's contentView
set theSubviews to theContentView's subviews as list
log theSubviews
(* (
"<NSPopUpButton: 0x200784fa0>",
"<NSScrollView: 0x2007bea20>",
"<NSScrollView: 0x20078cde0>"
)
Here is to try out whose item is what
*)
set scrollView1 to item 3 of theSubviews
set scrollView2 to item 2 of theSubviews
if choose is "Table View 1" then
scrollView1's setHidden_(false)
scrollView2's setHidden_(true)
else if choose is "Table View 2" then
scrollView1's setHidden_(true)
scrollView2's setHidden_(false)
end if
end chooseTableView_