nmm
asked on
SelectAll on Controlenter through MouseClick
Hi,
I use Delphi4
if you click (with mouse lButton) in a TCombobox's edit, you will see,
that the content will selected (if autoselect=true).
if you click in a TEdit (AutoSelect is true). nothing is selected and the
cursor is set near mouse-click position.
I want to have the same behaviour as in TComboBox. So I try to set
"OnEnter" of the TEdit to something like
procedure TForm1.ControlEnter(Sender : TObject);
begin
if sender is tedit then
with sender as Tedit do selectall;
end;
but this will not help...
How to get the text selected, if click to the TEdit?
(If you enter the TEdit with TAB or calling SetFocus, the Text will be selected.
Only if you use the mouse, it fails)
ANY idea?
nmm
I use Delphi4
if you click (with mouse lButton) in a TCombobox's edit, you will see,
that the content will selected (if autoselect=true).
if you click in a TEdit (AutoSelect is true). nothing is selected and the
cursor is set near mouse-click position.
I want to have the same behaviour as in TComboBox. So I try to set
"OnEnter" of the TEdit to something like
procedure TForm1.ControlEnter(Sender
begin
if sender is tedit then
with sender as Tedit do selectall;
end;
but this will not help...
How to get the text selected, if click to the TEdit?
(If you enter the TEdit with TAB or calling SetFocus, the Text will be selected.
Only if you use the mouse, it fails)
ANY idea?
nmm
hi,
just use a mouseevent like
procedure TForm1.Edit1MouseUp(Sender : TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (sender is TEdit) then
TEdit(Sender).SelectAll;
end;
meikl
just use a mouseevent like
procedure TForm1.Edit1MouseUp(Sender
Shift: TShiftState; X, Y: Integer);
begin
if (sender is TEdit) then
TEdit(Sender).SelectAll;
end;
meikl
ASKER
Thank you, but it does not work.
The mouseclick is used by Delphi (windows?) to set cursorpos *after*
processing OnEnter. So the selection is removed...
The solution from kretzschmar
is also not good, because than the usual mouseclick inside does not set cursorpos.
I want: if you click *first* in the TEdit (onEnter), all sould be selected, but if you click again it should behave "normal".
Just like TComboBox.
nmm
The mouseclick is used by Delphi (windows?) to set cursorpos *after*
processing OnEnter. So the selection is removed...
The solution from kretzschmar
is also not good, because than the usual mouseclick inside does not set cursorpos.
I want: if you click *first* in the TEdit (onEnter), all sould be selected, but if you click again it should behave "normal".
Just like TComboBox.
nmm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you DMN, it works and is just I need!
procedure TForm1.ControlEnter(Sender
begin
if sender is tedit then
with sender as Tedit do
begin
SelStart := 0;
SelLength := Length(Text);
end;
end;
Cheers,
Raymond.