Hey!
I’m working on a Palette plugin with multiple EditText fields. When used as a script I’m able to cycle through fields using the Tab key, but not since I moved my code to the plugin Template. How can I do that?
Where is the view? In a dialog? vanilla or interface builder?
Yes, it’s vanilla:
def settings(self):
self.w = Window((w, h))
self.w.group = Group((0, 0, w, h))
self.w.group.L = EditText( ( m, yPos, -(w/2)-(m/2), fh), placeholder="Left", sizeStyle="small")
self.w.group.R = EditText( ( (w/2)+(m/2), yPos, -m, fh), placeholder="Right", sizeStyle="small")
#rest of UI
self.dialog = self.w.group.getNSView()
It might be the switching from one window to the other. Can you build the dialog fully in vanilla, skipping the self.dialog
part?
I’m not sure how I should add my Group to the palette without the self.dialog
part? But I think the issue is what you pointed out, because if I just self.w.group.open()
my vanilla window from the plugin, the tab key is working.
I meant build the dialog fully in vanilla, including the OK and Cancel buttons.
Or build the UI in Xcode.
Wait, are we still talking about a Palette plugin?
Btw, this is related to that other topic.
I missed that.
You can try to set the nextResponder of the textfields manually. But that might only make a difference when the view is in the new window already.
Facing the same issue in a palette plugin with vanilla, could you please explain how to set nextResponder? I tried naively editText. nextResponder = nextEditText, but that of course doesn’t work.
I would try something like:
myVanillaTextField.getNSTextField().setNextResponder_(myNextVanillaThingy.getNSTextField())
One addition. The argument to setNextResponder needs to be myNextVanillaThingy. getNSTextField()
Thank you! I tried this, but it seems like setNextResponder_ doesn’t change anything:
from vanilla import EditText
a = EditText((10, 10, 10, 10))
b = EditText((10, 10, 10, 10))
print( a.getNSTextField().nextResponder.self )
a.getNSTextField().setNextResponder_( b.getNSTextField() )
print( a.getNSTextField().nextResponder.self )
print( b.getNSTextField() )
Print gives:
<VNSTextField: 0x7fd69f83ac00> # before setNextResponder_
<VNSTextField: 0x7fd69f83ac00> # after setNextResponder_
<VNSTextField: 0x7fd6eeaa8a00> # but this is expected after setNextResponder_
Am I getting it wrongly?
The views need to be in a window to be able to have a next responder. And the window is usually setting the view loop: Apple Developer Documentation
Thaaanks! Made it work with
window.getNSWindow().recalculateKeyViewLoop()
after all elements.