I'm using sap.m.TabContainer with items containing sap.m.TextArea's. If I switch between tabs, the cursor position in the textarea's is reseted. I would like to keep the cursor position in the textarea's. Is there a possibility to store the current cursor position bevor leave and set the stored position on enter of the textarea? Regards, Annie
sap.m.TextArea
inherits from the sap.m.InputBase
which provides focus related APIs e.g. getFocusInfo
and applyFocusInfo
.
To get notified when the user enters or leaves the textarea you can add onfocusin
and onfocusout
as an event delegate and then store the focus info on focusout and apply the stored focus info on focusin. E.g.:
var oFocusDelegate = {
mFocusInfo: {},
onfocusin: function(oEvent) {
var oTextArea = oEvent.srcControl;
var mFocusInfo = this.mFocusInfo[oTextArea];
if (mFocusInfo) {
oTextArea.applyFocusInfo(mFocusInfo);
}
},
onfocusout: function(oEvent) {
var oTextArea = oEvent.srcControl;
this.mFocusInfo[oTextArea] = oTextArea.getFocusInfo();
}
};
// add focus delegate to textareas
// TextArea required from "sap/m/TextArea"
new TextArea().addEventDelegate(oFocusDelegate);
Please see: https://jsbin.com/wusejifili/1/edit?html,output