Selection with TEdit component
Posted on 2002-04-21
I have a TEdit component on a form and I would like to make it so that when the user initially clicks on the TEdit, all of the text is selected (so the user can easily type something to replace it). However, the user should still be allowed to select a range with the mouse themselves without having all of the text selected. To demonstrate what I mean, take a look at the URL edit box in Internet Explorer.
Could you please give me any sample code that would do this?
The closest I've got is this...
procedure TMain.EditBoxClick(Sender: TObject);
if EditBox.SelLength = 0 then EditBox.SelectAll;
The above almost works, but clicking with the mouse to the right of the text automatically selects all of the text, which I do not want. I only want the SelectAll to take place when the user initially clicks on the edit box.
Thanks in Advance,