Tab機能の拡張を諦める。¶
VisualにTabを選択したいため、タブを一覧表示で、カレントなWindowを示すコードを書こうとした。

一応、以下の非公開メソッドを使うことでできそうだが実装は諦める。
tabの切り替えのための over view の画面は格好良いけど、"select next tab"にショートカットをつける方が画面がすぐに変わるので便利だ。
つまり、以下のコードを無駄。
@IBAction func log(_ sender: Any?)
{
if let theStack = self.window!.value(forKeyPath:
"windowStackController.tabPickerViewController.tabPickerController" ) as? NSViewController
{
if let orderedTabViewItems = theStack.value(forKey: "orderedTabViewItems") as? NSArray
{
if let indexOfSelectedTab = theStack.value(forKey: "indexOfSelectedTab") as? NSNumber
{
if let theSelectedObject = orderedTabViewItems.object(at: indexOfSelectedTab.intValue) as? NSObject
{
// タイトルを" this is a Current Tab "に変更
theSelectedObject.setValue("this is a Current Tab", forKey: "label")
// 再描画させる
theStack.perform(NSSelectorFromString("reloadTabBarItem:"), with: theSelectedObject)
}
}
}
}
}
Comments
comments powered by Disqus