Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2020-05

TComboBox.ReadOnly

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Regarding issue:
https://bugs.freepascal.org/view.php?id=36978

TComboBox ReadOnly was deprecated in r55243 by reason is mentioned but I believe it had good reasons. The deprecated message was updated in r59467 by deprecated message says: "use extended Style values instead." How exactly should they be used to get the old ReadOnly behavior?

The deprecated message says the ReadOnly property will be removed in Lazarus 2.2.
I removed it and fixed the numerous side effects. The changes are in the attached patch.
There may be more side effects, I only tested with packages that happened to be installed here.
Is it OK to apply?

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200501/294afa41/attachment.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-LCL-Remove-deprecated-TComboBox.ReadOnly.patch Type: text/x-patch
Size: 4575 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200501/294afa41/attachment.bin>

Reply by email

Ondrej Pokorny
to Juha Manninen
Juha Manninen wrote 5 lines
I applied my own patch. It removes the deprecated published property so it will be gone in Lazarus 2.2. A public ReadOnly property remains but is cannot be assigned any more. Thus ReadOnly property is itself readonly. :) Please test.

From what I can see the ReadOnly property is still published. I would remove it completely, there is no reason to have it anymore if it was deprecated for 3 years. Not even in the public section. (Again, even with ReadOnly=True you can still change the value with the drop down.)

As for Jamie's issue. I took a look at the state before I deprecated it and it was a way to disable editing for csOwnerDrawFixed, csOwnerDrawVariable styles - so actually a duplicate property for the Style property. It had no other function.

It was not an equivalent for a "readonly edit" (=you can select text but cannot change it by typing) and enabled drop-down list. Something that can be achieved with EM_SETREADONLY as described in http://mc-computing.com/Languages/Delphi/ReadOnly.html

This works in Lazarus as well:
procedure TForm1.Button1Click(Sender: TObject);
begin
   // make combobox read-only (make sure ComboBox1.Style=csDropDown)
   SendMessage(GetWindow(ComboBox1.Handle, GW_CHILD), EM_SETREADONLY,
Ord(True), 0);
end;

So, IMO the removal of the ReadOnly property is valid because it was not implemented with EM_SETREADONLY as Jamie expected and was only confusing the way it was implemented.

Ondrej

Reply by email

Juha Manninen
to Ondrej Pokorny

On Sat, May 2, 2020 at 9:09 AM Ondrej Pokorny via lazarus <

Show quoted text 7 lines
wrote: From what I can see the ReadOnly property is still published. I would remove it completely, there is no reason to have it anymore if it was deprecated for 3 years. Not even in the public section. (Again, even with ReadOnly=True you can still change the value with the drop down.)

No, the published property is gone. You must rebuild the IDE before it disappears from OI.
There is a public TCustomComboBox.ReadOnly :

    property ReadOnly: Boolean read GetReadOnly stored False;
...
function TCustomComboBox.GetReadOnly: Boolean;
begin
  Result := Style in [csDropDownList, csOwnerDrawFixed,
csOwnerDrawVariable];
end;

This works in Lazarus as well:

Show quoted text 7 lines
procedure TForm1.Button1Click(Sender: TObject); begin // make combobox read-only (make sure ComboBox1.Style=csDropDown) SendMessage(GetWindow(ComboBox1.Handle, GW_CHILD), EM_SETREADONLY, Ord(True), 0); end;

Works only with LCL-Win32.
I just realized that a custom cross-platform component could easily be inherited from TCustomEditButton. It is the ancestor of TFilenameEdit, TDateEdit etc.
It makes sense if you need many instances of those controls. Otherwise a TEdit + anchored dropdown button suffices.
Such a custom component will not be added to LCL however because TComboBox and TComboBoxEx are enough for most people.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200502/0c48dd29/attachment.html>

Reply by email

Ondrej Pokorny
to Juha Manninen
Juha Manninen wrote 13 lines
On Sat, May 2, 2020 at 9:09 AM Ondrej Pokorny via lazarus < <mailto:>> wrote: From what I can see the ReadOnly property is still published. I would remove it completely, there is no reason to have it anymore if it was deprecated for 3 years. Not even in the public section. (Again, even with ReadOnly=True you can still change the value with the drop down.) No, the published property is gone. You must rebuild the IDE before it disappears from OI. There is a public TCustomComboBox.ReadOnly

Yes, sorry - you are right. I missed that. I would just remove it.

Show quoted text 11 lines
This works in Lazarus as well: procedure TForm1.Button1Click(Sender: TObject); begin    // make combobox read-only (make sure ComboBox1.Style=csDropDown)    SendMessage(GetWindow(ComboBox1.Handle, GW_CHILD), EM_SETREADONLY, Ord(True), 0); end; Works only with LCL-Win32.

That's obvious :) I wanted to stress that we never had a ReadOnly property Jamie wanted so there was nothing to be re-enabled. Also, Delphi never had it so he was wrong about "I understand latest Delphi eliminated it [ReadOnly property]".

Ondrej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200502/afcc6dc5/attachment-0001.html>

Reply by email

Werner Pamler
to Juha Manninen: On Sat, May 2, 2020 at 11:37 AM Ondrej Pokorny via lazarus < Ok, I removed it in r63112.…
Juha Manninen wrote
Ok, I removed it in r63112.

Something must be screwed up in TComboboxEx. Don't worry, not by the removal of the ReadOnly property, but it must have been around for a long time since the beginning: This component introduces a new Style type: TComboboxExStyle = (csExDropDown, csExSimple, csExDropDownList). In Delphi it is possible to type text into the control when the Style is csExDropDown or csExSimple, but in Lazarus this is not possible, the control behaves like csExDropDownList in all cases (except for the grayed appearance, in Windows). And in Delphi the Style with csExSimple looks like a simple TEdit, while in Lazarus it has the dropdown arrow, like the csExDropdown(List) Style.

I tested this on Windows, and Linux gtk2 and qt5.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200502/b2c615bf/attachment.html>

Reply by email