* * *

Author Topic: TLabel over TPanel  (Read 565 times)

wittbo

  • New member
  • *
  • Posts: 24
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-
Lazarus 1.6.4  with FPC 3.0.2
MacOS 10.10.5

taazz

  • Hero Member
  • *****
  • Posts: 4485
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: 529
    • My "almost daily" development blog
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).
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

taazz

  • Hero Member
  • *****
  • Posts: 4485
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

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus