0

I try to set an NSTabView delegate using MacRuby with XCode, but I can't figure how to write the delegate. I use:

def intialize
@tab_changed.delegate = self
end

def tabViewdidSelectTabViewItem(a_notification)
puts "tab has changed"
end

Then in the .xib, I hook the NSTab view element with the class, but nothing happen when I select some tabs. Usually the delegate are very easy to use, but this one has a syntax like this : tabView:didSelectTabViewItem:

and I don't know how to write this in MacRuby. Should I use tabViewdidSelectTabViewItem or tabView_didSelectTabViewItem (none of them works).

Thanks for your help.

scandella
  • 21
  • 3

1 Answers1

0

Assuming this is being done in a ViewController, instead of using initialize, better to do things the Cocoa way and use a method like viewDidLoad.

def viewDidLoad
   @tab_changed.delegate = self
end

The signature for the delegate method you want is -(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem. In MacRuby, that would be represented like this:

def tabView(tabView, didSelectTabViewItem: tabViewItem)
   puts "tab has changed"
end
jtomschroeder
  • 1,034
  • 7
  • 11