[Lazarus] TComboBox.ReadOnly

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
Regarding issue:

TComboBox ReadOnly was deprecated in r55243 by Ondrej at 2017-06-05.
No reason is mentioned but I believe it had good reasons.
The deprecated message was updated in r59467 by Mattias at 2018-11-06.

The 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


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

0001-LCL-Remove-deprecated-TComboBox.ReadOnly.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
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.

Juha


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
On 01.05.2020 23:36, Juha Manninen via lazarus wrote:
> 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

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
On Sat, May 2, 2020 at 9:09 AM Ondrej Pokorny via lazarus <[hidden email]> 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:
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


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
On 02.05.2020 09:00, Juha Manninen via lazarus wrote:
On Sat, May 2, 2020 at 9:09 AM Ondrej Pokorny via lazarus <[hidden email]> 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.


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


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
On Sat, May 2, 2020 at 11:37 AM Ondrej Pokorny via lazarus <[hidden email]> wrote:
Yes, sorry - you are right. I missed that. I would just remove it.

Ok, I removed it in r63112.

Juha


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
On 02.05.2020 16:15, Juha Manninen via lazarus wrote:
On Sat, May 2, 2020 at 11:37 AM Ondrej Pokorny via lazarus <[hidden email]> wrote:
Yes, sorry - you are right. I missed that. I would just remove it.

Ok, I removed it in r63112.

Great, thank you, Juha!

Ondrej


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TComboBox.ReadOnly

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
Am 02.05.2020 um 16:15 schrieb Juha Manninen via lazarus:
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.


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus