Question

InputBox: How to add autofocus on TextEdit?

Hi

 

I'm using Terrasoft.utils.inputBox to get a text value.

var buttons = [
	Terrasoft.MessageBoxButtons.SAVE,
	Terrasoft.MessageBoxButtons.CANCEL
];
Terrasoft.utils.inputBox(caption, function(result, arg) {
	if (result === Terrasoft.MessageBoxButtons.SAVE.returnCode) {
	}	
},
buttons, 
this,
{
	textValue: {
		"dataValueType": 1,
		"caption": "New folder"
	}	
});	

And I'd like to add autofocus on the text input.

Any idea how to do that.

 

Thank you

Mohamed

Like 0

Like

1 comments

Hi Mohamed,

 

It depends on where you are going to use this modal box. For example I've added the button to AccountSectionV2 and the modal box is opened upon clicking the button. To make sure that the string field inside the modal box is focused I've used this function:

 

document.getElementsByClassName("base-edit-input ts-box-sizing")[1].focus();

Element with the first index is selected since element with 0 index is the "Global search" string at the very top right corner of the page. But there can be more text edit fields on the page where the modal box is initialized and it should be also taken into account.

 

This is the easiest way to implement the functionality you need.

 

Best regards,

Oscar

Show all comments