[Lazarus] Opinions required on what the ReadOnly property should do for LCL controls.

coppolastudio at virgilio.it coppolastudio at virgilio.it
Fri Feb 22 11:15:56 CET 2008


What you say is right for single component but not for composite 
components like edit&button. In fact you cannot type on a button but 
you can do that on a edit.
Due to different date format (short long and 
so on) the original idea was to select a date by a calendar and not by 
typing. In this way the user bypass the date format.
Regards,
Salvatore

---------------------------------------------------------------------- 
 Gerard Visent - 2008-02-21 16:49  
---------------------------------------------------------------------- 
Salvatore:

No, I dind't confuse ReadOnly with Enabled.

>From the VCL 
ref.:

TControl.Enabled: Use Enabled to change the availability of the 
control to
the user. To disable a control, set Enabled to false. 
Disabled controls
appear dimmed. If Enabled is false, the control 
ignores mouse, keyboard,
and timer events.
To re-enable a control, set 
Enabled to true. The control is no longer
dimmed, and the user can use 
the control. 

TCustomEdit.ReadOnly: To restrict the edit control to 
display only, set
the ReadOnly property to true. Set ReadOnly to false 
to allow the contents
of the edit control to be edited.

Setting 
ReadOnly to true ensures that the text is not altered, while still
allowing the user to select text. The selected text can then be 
manipulated
by the application, or copied to the Clipboard.

Many other 
components or classes (TDBGrid, TColumn, TEdit, TField, All DB
controls 
that allow editing) also have a ReadOnly property wich is used in
the 
same way.
This way, if you want to lock some fields on a form while 
others can be
edited (a very common behaviour in many apps), you just 
set them to
ReadOnly.
If we go the other way, not only will you have to 
set enabled for some
controls and not for others, but for those that 
are disabled the user won't
be able to select  the text and copy.

Now, 
you can always say that we don't have to abide to VCL compatibility
or 
even common sense <g>





More information about the Lazarus mailing list