User Tools

Site Tools


how_to_highlight_all_the_text_in_a_control_when_it_gets_focus_by_a_mouse_click.htm
Navigation:  How To's and Troubleshooting > How to… >====== How to highlight all the text in a control when it gets focus by a mouse click ====== Previous pageReturn to chapter overviewNext page

When you tab to an entry control with the tab key, the entire entry field plus any existing text, is highlighted. Then, when you begin typing, the highlighted text is immediately overwritten. However, when you select an entry control with the mouse, you get an I-beam insertion point somewhere inside the entry field, and existing text is not highlighted.

To force a mouse selection to behave like the tab key, add MouseLeft to the list of Alert keys for the control, then embed some code to “select” the entire field when the mouse is CLICKED:

1.From the Window Designer, RIGHT-CLICK the control and choose Alert from the popup menu.

2.From the Alert Keys dialog, press the Add button.

3.From the Input Key dialog, CLICK on Left Button in the Mouse group.

4.Press OK twice to return to the Window Designer.

5.From the Window Designer, RIGHT-CLICK the control and choose Embeds from the popup menu.

6.Add the following code to the EVENT:AlertKey embed point for the control:

IF KEYCODE() = MouseLeft

 SELECT(?,LEN(?{PROP:ScreenText}))

 ?{PROP:SelStart} = 1

 ?{PROP:SelEnd} = LEN(?{PROP:ScreenText})

END

how_to_highlight_all_the_text_in_a_control_when_it_gets_focus_by_a_mouse_click.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1