ccgus / CocoaScript

JavaScript + the Cocoa frameworks, and then ObjC brackets show up to party as well.
Other
618 stars 58 forks source link

Focusing issues on Sierra when using COSAlertWindow #45

Closed bomberstudios closed 8 years ago

bomberstudios commented 8 years ago

We've had a few reports from plugin developers about this issue. Here's an example:

I was working on the upload of bunch new feature for my plugin https://github.com/vincenzopetito/Shapr

I've noticed that on Sierra when I run the shortcut and open the window I cannot switch between inputs as I did before on ElCapitan, plus the first input field is not automatically focused.

They're using COSAlertWindow on their code.

Another developer told us that:

For this to work in Sierra you can explicitly define the initialFirstResponder for the alert window and nextKeyView for each NSTextField.

Here's an example:

var alert = COSAlertWindow.new();
alert.addTextFieldWithValue("");
alert.addTextFieldWithValue("");
var firstField = alert.viewAtIndex(0);
var secondField = alert.viewAtIndex(1);
alert.alert().window().setInitialFirstResponder(firstField)
firstField.setNextKeyView(secondField)
alert.runModal()

Is this something that could be improved in https://github.com/ccgus/CocoaScript/blob/master/src/framework/COSAlertWindow.m?

ccgus commented 8 years ago

I find it works better in 10.12.1 like so:

var alert = COSAlertWindow.new();
alert.addTextFieldWithValue("");
alert.addTextFieldWithValue("");
alert.runModal()

In the example you gave me, the next key loop stops at the second field, and doesn't tab over to the OK button.

So I don't think there's anything Cocoa Script should change.

bomberstudios commented 8 years ago

Indeed, this seems to work as expected on 10.12.1. Closing!