TEdit Child Controls -- Delphi Compatability
Original Reporter info from Mantis: mtrsoft
-
Reporter name: John Raycheba
Original Reporter info from Mantis: mtrsoft
- Reporter name: John Raycheba
Description:
The basic issue is that if a TEdit can not have child controls while it can in Delph XE2 and earlier. (I have not checked more recent Delphi versions.)
THE USE CASE:
To create "light weight" edit buttons and similar controls. (Yes, I do know that Lazarus already has a TEdotButton control.)
Steps to reproduce:
-
Create a new project.
-
Place a TEdit control on the main form.
-
Try to place another control, such as a TButton, on the TEdit. -- The control will overlap with the TEdit, BUT the Object Inspector shows that the Button is NOT a child of the TEdit. -- This works in Delphi.
-
For comparison place a TPanel on the form.
-
Try to place a TButton on the TPanel. -- The Object Inspector shows that the TButton IS a child of the TPanel.
Additional information:
A QUICK FIX:
In the file c:\Lazarus\LCL\includes\customedit.inc
Starting at line 472 change the function TCustomEdit.ChildClassAllowed from:
function TCustomEdit.ChildClassAllowed(ChildClass: TClass): boolean;
begin
// no children
Result := False;
if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True;
end;
to:
function TCustomEdit.ChildClassAllowed(ChildClass: TClass): boolean;
begin
// no children
//Result := False;
//JR: Was not able to locate where in the Widgetset the lcAllowChildControlsInNativeControls is set, so just commented out and set result to true.
//if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True; //JR: Commentted out.
Result := True; //JR: Allow TEdit to have child controls, such as buttons, etc.
end;
I assume that the proper way to fix this is to change the value of "lcAllowChildControlsInNativeControls" as this issue MAY apply to other controls and other OSs.
Unfortunately, I was not able to locate the code that sets this variable / constant.
Mantis conversion info:
- Mantis ID: 36513
- OS: Windows
- Build: 61665
- Platform: Win7x32, All?
- Version: 2.0.4
- Fixed in revision: 62572 (#0c33b3e2)