The view method has to return a view, not a view controller. My code snippet would need to go into inspectorViewControllersForLayer_(). But your hack to return [self] works, too. I fixed the code but can’t push the changes. Can you add me to the repo?
Hi! I’m trying to add a mouseUp callback to a vanilla TextBox via subclassing, but it removes the view’s background when its on the Info panel. Since I super() everything else, I don’t get where that change comes from. Any hints please?
try:
ClickableTextBoxView
except NameError:
class ClickableTextBoxView(TextBox.nsTextFieldClass):
def mouseUp_(self, event):
if hasattr(self, 'mouseUpCallback') and self.mouseUpCallback:
self.mouseUpCallback(event)
class ClickableTextBox(TextBox):
nsTextFieldClass = ClickableTextBoxView
def __init__(self, *args, **kwargs):
self.mouseUpCallback = kwargs.pop('mouseUpCallback', None)
super(ClickableTextBox, self).__init__(*args, **kwargs)
self._nsObject.mouseUpCallback = self.mouseUpCallback
Out of curiosity: why do you need the mouseUp on this textField? There is also the NSTextFieldDelegate with methods like textDidEndEditing: or textDidChange:, in case those could happen to be closer to what you want to do. textDidEndEditing: is called any time the text object has finished editing (that it has resigned first responder status). So this is also, when the user hits the enter key, or tab, or clicks outside if the text field.