Recent

Author Topic: TLabel over TPanel  (Read 5206 times)

wittbo

  • Full Member
  • ***
  • Posts: 150
TLabel over TPanel
« on: August 06, 2017, 12:16:57 am »
Hello,
inspired by carl_caulketts solution of a movable Panel (in the macOS subsection), i developed a movable Label as cross platform drag&drop solution, since drag&drop does not seem to be implemented on macOS/cocoa. OK, everything works fine, moving and dragging the label no problem, macOS/carbon and macOS/cocoa ok. But, after compiling and running with windows XP, the Label disappears behind the Panel, whereas with macOS the TLabel floats in front of the TPanel, shit.
Which is the to be expected behavior, the macOS or the windows behavior? Why is one of the platforms wrong?
Any idea?
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TLabel over TPanel
« Reply #1 on: August 06, 2017, 12:33:55 am »
a Tlabel is a TGraphicControl descendant. TGraphiControls can be considered as virtual controls they do not exists from the system's point of view they are handled completely from the framework, as such they are painted when their parent is painted, as a result they are always painted before all the TWinControl descendant children, which handle communication with the OS on their own. That is on windows at least and probably QT as well.

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Eugene Loza

  • Hero Member
  • *****
  • Posts: 663
    • My games in Pascal
Re: TLabel over TPanel
« Reply #2 on: August 06, 2017, 01:27:37 am »
Quote
compiling and running with windows XP, the Label disappears behind the Panel
I can't compile the project on Linux. For some reason CarbonBars (which is not in "uses") argues that it requires MacOSAll.
I've tried to override z-order of the classes for a clean test project, but in any case TPanel draws over TLabel unless it's "visible=false". While z-order works perfectly for 2 TPanels, and also for TEdit, TButton, TMemo, etc... only TLabel seems to be ignored completely... Really unexpected.
Only assigning TLabel parent to be TPanel it is drawn over TPanel (but not over TForm anymore).

I can see the only workaround:
Make the label not a TLabel, but a TPanel with BevelOuter=bvNone, thou you can only have a label over a color this way, you can't make it transparent (showing only text).
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TLabel over TPanel
« Reply #3 on: August 06, 2017, 01:31:47 am »
Make the label not a TLabel, but a TPanel with BevelOuter=bvNone, thou you can only have a label over a color this way, you can't make it transparent (showing only text).
use tstatictext instead of tpanel.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018