Recent

Author Topic: [Answered] Any "windowed" TLabel?  (Read 1543 times)

devEric69

  • Hero Member
  • *****
  • Posts: 648
[Answered] Any "windowed" TLabel?
« on: September 21, 2021, 02:25:07 pm »
Hello,

In Delphi, there is \ was - from memory - a "windowed" TLabel with its THandle. So, the characteristic of such a control, is that it allows to select at runtime the caption-text with the mouse, like in a read-only TEdit. Is there a similar component in Lazarus\LCL or in a third-party package (AFAIK, the basic TLabel doesn't allow a runtime selection of its displayed caption-text).

Regards.
« Last Edit: September 22, 2021, 09:28:53 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: Any "windowed" TLabel?
« Reply #1 on: September 21, 2021, 03:06:09 pm »
https://wiki.freepascal.org/TStaticText
Not sure it supports the selection.

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Any "windowed" TLabel?
« Reply #2 on: September 21, 2021, 03:26:19 pm »
Not sure it supports the selection.

Thanks @Alextp. Indeed, it's a descendant of TWinControl. So, the equivalent of what I've described. However, at runtime, under Linux + LCLWidgesetType=gtk2, I cannot select it, in order to highlight the TStaticText's caption-text and to copy it inside the clipboard :( (did I miss anything?).

==> does anyone know such a TLabel visual control that allows this?
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Zvoni

  • Hero Member
  • *****
  • Posts: 2300
Re: Any "windowed" TLabel?
« Reply #3 on: September 21, 2021, 03:41:39 pm »
Why not just use a TEdit with ReadOnly = True ?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Any "windowed" TLabel?
« Reply #4 on: September 21, 2021, 03:51:42 pm »
Well, that's what I'm doing at the moment (TEdit, with no border, and read-only mode). Now, I've this souvenir in Delphi. Hence my question (curiosity).
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1311
    • Lebeau Software
Re: Any "windowed" TLabel?
« Reply #5 on: September 21, 2021, 08:46:19 pm »
Now, I've this souvenir in Delphi. Hence my question (curiosity).

AFAIK, TStaticText in Delphi doesn't support selections, either.  It is just a thin wrapper around a Win32 STATIC control, which MSDN says:

About Static Controls

Quote
Although static controls are child windows, they cannot be selected.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Any "windowed" TLabel?
« Reply #6 on: September 22, 2021, 09:28:27 am »
Hello @Remy Lebeau,

Thank you for these technical precisions emanating from MS-Windows itself. Indeed, there doesn't seem to be a ready-made selectable label in Delphi (bad memory, sorry).
On the other hand, it seems not very complicated to automate the copy-paste of the caption inside the clipboard:

Code: Pascal  [Select][+][-]
  1. type
  2.   TcopyingLabel = class(TLabel)
  3.     private
  4.     protected
  5.         procedure Click; override;
  6.     public
  7.     published
  8.   end;
  9.  
  10. procedure Register;
  11.  
  12. implementation
  13.  
  14. uses Clipbrd;
  15.  
  16. procedure Register;
  17. begin
  18.      RegisterComponents('Standard', [TcopyingLabel]);
  19. end;
  20.  
  21. procedure TcopyingLabel.Click;
  22. begin
  23.      Clipboard.AsText:= Self.Caption;
  24.      { behaviorial click of inherited parent }
  25.      inherited Click;
  26. end;
« Last Edit: September 22, 2021, 09:32:37 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018