LiveCode LessonsData GridLiveCode Data GridUsing The Built-In Field EditorHow Can I Select The Text in the Edit Field When It Opens?

How Can I Select The Text in the Edit Field When It Opens?

The default Data Grid behavior when editing cell contents is to put the cursor at the end of the field. This lesson will show you how to tell the Data Grid that all of the cell text should be selected.

The technique described requires that you create a custom column behavior as outlined in this lesson.

The Default Behavior

The Default Behavior

By default the Data Grid will not select the text of a cell when you start editing a value.

Selecting The Text

Selecting The Text

You can tell the Data Grid to select all of the text by setting a special custom property called dgTemplateFieldEditor. If you set the dgTemplateFieldEditor["select text"] of the Data Grid to true then the data Grid will select the cell text.

set the dgTemplateFieldEditor["select text"] of the dgControl of me to true

An Example Script

An Example Script

You can add this line of text to the EditValue handler in your custom column behavior. Just place the code right before the call to EditFieldText.

## Select all text before opening
set the dgTemplateFieldEditor["select text"] of the dgControl of me to true

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.