Reputation: 13
How can I get the element with the currently active focus in a SimpleForm?
I have already tried with getFocusInfo()
, but I have information if the element I try to select has an active focus
Upvotes: 1
Views: 1909
Reputation: 18064
You can get the current focused control like this:
// Element required from "sap/ui/core/Element"
Element.getActiveElement();
API Reference: sap.ui.core.Element.getActiveElement
// Core required from "sap/ui/core/Core"
getCurrentFocusedControl: function() {
const currentFocusedControlId = Core.getCurrentFocusedControlId(); // deprecated since 1.119
return Core.byId(currentFocusedControlId); // deprecated since 1.119
},
API Reference: sap.ui.core.Core#getCurrentFocusedControlId
Upvotes: 2