Recent

Author Topic: TLabel, when Caption empty, can't drag it in form  (Read 4628 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
TLabel, when Caption empty, can't drag it in form
« on: July 22, 2011, 07:47:12 pm »
Hi dear forum people,

I find that when I have an Tlabel with an empty Caption, It becomes like a single pixel and the mouse can't seem to grab it in order to move it.

I even tried lazo'ing it by framing it with the mouse, but that did not seem to work either.

So, in order to place it by dragging, I had to put some text in the Caption and then it can be moved.

Any comments on this that I'd be missing, so I can move it without having to put text as said?

Thanks.

haiti meid

  • New Member
  • *
  • Posts: 12
    • open up
Re: TLabel, when Caption empty, can't drag it in form
« Reply #1 on: July 22, 2011, 07:51:55 pm »
Select it in Object Inspector window. Then set its top/left properties.

But what are you doing pal? Sounds like an abnormal job  :)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TLabel, when Caption empty, can't drag it in form
« Reply #2 on: July 22, 2011, 07:52:50 pm »
Set AutoSize property of TLabel to False. Then you can have an empty Caption.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: TLabel, when Caption empty, can't drag it in form
« Reply #3 on: July 22, 2011, 08:12:48 pm »
Set AutoSize property of TLabel to False. Then you can have an empty Caption.

Thanks for the suggestions, Typo.

What am I doing is "cute/useful" (for me) as follows: I have the Tlabel empty, and in it I can put error messages handled by my procedures or functions.

That means that the error message appears always in a fixed place, without one expecting it, since it does not show at all during the form (you can't see any thing unless there's an error message). The code also clears it as needed. The TLabel is by default transparent and I leave it as such.

The other thing is that since TLabel automatically sizes itself to fit the text given to it, there's no need to worry too much about the length of the message one puts into it. I also have the text come up in red, which suites an error message.

Anyhow, I gather that it's not a bad way to put text in the caption, then I can drag it, then change that property to empty.

But anyhow, I thought that it should be movable, even if it is empty, for consistency (and that's what I was wondering if it is possible or should be made possible).

Thanks, Typo.
« Last Edit: July 22, 2011, 08:14:49 pm by Elmug »

vvzh

  • Jr. Member
  • **
  • Posts: 58
Re: TLabel, when Caption empty, can't drag it in form
« Reply #4 on: July 22, 2011, 10:40:00 pm »
The problem is, when TLabel.AutoSize is True TLabel collapses to fit text width, so for empty text its width become zero and TLabel has no inner pixels to start dragging.

To avoid this you can set TLabel.Constraints.MinWidth to something greater than zero (e.g. 15). TLabel.Width is never less than MinWidth so you will get some space to catch the label and drag it around. This way you can also set AutoSize back to True allowing your label to adjust to the text width again.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: TLabel, when Caption empty, can't drag it in form
« Reply #5 on: July 22, 2011, 10:48:45 pm »
The problem is, when TLabel.AutoSize is True TLabel collapses to fit text width, so for empty text its width become zero and TLabel has no inner pixels to start dragging.

To avoid this you can set TLabel.Constraints.MinWidth to something greater than zero (e.g. 15). TLabel.Width is never less than MinWidth so you will get some space to catch the label and drag it around. This way you can also set AutoSize back to True allowing your label to adjust to the text width again.

Thanks. That is clear and I get it.

Just for the current need, though, I'll just put some text in it, which allows me to drag it. At any time, when label with variable contents shows up well, then I'll just change the caption to ''. This way, actually, while developing, I also see that temporary text.

So, actually, it's not a big deal nor problem now that I've been explained it various ways.

And if it has no inner pixels, I suppose that prevents the mouse to lazzo it and drag it. Hm...I can see a pixel but I can not move it!

Thanks everyone.
« Last Edit: July 22, 2011, 11:41:38 pm by Elmug »

 

TinyPortal © 2005-2018