@Boghyon Hoffman's approach is right, but it did not work for me. The delegate was not called on 1.126 (did not test it on another version).
I had to use it this way, by assigning the function to as a property in the object.
I have moved it to a base controller, that way it can be used in multiple controllers, with a oneliner:
BaseController:
setInitialFocus: function(sControlId) {
var oView = this.getView();
var oControl = oView.byId(sControlId);
var fnAfterShow = function() {
if (oControl && !oControl.isDestroyed()) {
oControl.focus();
}
};
oView.addEventDelegate({
onAfterShow: fnAfterShow
});
}
Another controller:
onInit() {
this.setInitialFocus("someControl");
}
Do not forget to disable the autofocus on the App control level.