Recent

Author Topic: Enabled (and visible) not the same with BitBtn and FileNameEdit  (Read 4068 times)

stephanos

  • Jr. Member
  • **
  • Posts: 79
Dear All

I have been fiddling with this issue for half a day and been through the options in the object inspector several times,  I have several pdf manuals and they do not address this issue directly.  A web search has not revealed a resolution either.  The closest I have come is this tutorial:
https://wiki.freepascal.org/Lazarus_Tutorial

Please see openingscreen.pdf.  All four objects are not enabled but are visible.  But the two types of objects respond differently.

The Intention is that on create form the first object, FileNameEdit2 (Open the m3u file) is enabled and visible.  (Not shown in the picture as I was experimenting), FileNameEdit1 (Append file(s)) is not enabled and is visible, BitBtn6 (Open ErrorMessages.txt) is not enabled and is visible and,
BitBtn4 (Calculate Play Time) is not enabled and is visible. After the Open the m3u file is used, the remaining 3 objects will be enabled and visible.

That is how I have coded in the object inspector.  However, a BitBtn and a FileNameEdit do not grey out to the same extent.  A FileNameEdit is denser than a BitBtn.

Is this difference resolvable or do I have to live with it?

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1567
    • Lebeau Software
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #1 on: August 10, 2025, 03:48:55 pm »
This is explained in the documentation:

https://lazarus-ccr.sourceforge.io/docs/lcl/buttons/tcustombitbtn.glyph.html

https://lazarus-ccr.sourceforge.io/docs/lcl/buttons/tcustombitbtn.numglyphs.html

So, to make the button display differently when it's disabled, you can either define a Glyph that includes a disabled image, or you can assign an ImageList to the Images property and set the DisabledImageIndex property.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #2 on: August 10, 2025, 08:49:14 pm »
Thanks, lots of feedback and reading to do.

Regarding “So I assume you are referring to the image itself not showing a grey effect?”
It is not just the glyph that is not grey out, but the text labels as well.  “Calculate Play Time” text  is greyer than Append Files, when both are Visible and not enabled.
Also, those two BitBtn’s had a single glyph which automatically became less defined/greyed out when not enabled.  Am I asking too much to expect FileNameEdit to behave the same?

I have made a first reading of the info at lazarus-ccr.sourceforge.io.  I may come back with lots of questions as the terminology is new.

Thanks and wait to hear

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #3 on: August 11, 2025, 12:10:22 am »
This is a bit confusing, I don't see neither a "Calculate Play Time" nor an "Append File" text in your screenshot.

Here is what I get for Windows 11 (top) and Linux/gtk2 (bottom) when several standard controls are toggled between enabled and disabled states - looks rather uniform to me.
« Last Edit: August 11, 2025, 12:18:13 am by wp »

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #4 on: August 11, 2025, 11:11:50 am »
Dear WP

Here is the screenshot again.  I checked it is the same as the opening post

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #5 on: August 14, 2025, 08:05:57 pm »
Dear All

I was attracted to trying this solution: “you can assign an ImageList to the Images property and set the DisabledImageIndex property.” because it appeared to be saying I will be using one image and the object inspector will set the greyed out (image and text) status. 

I tried but, even additional web searches on images property in Lazarus found nothing useful.

Sorry everyone but I am at a loss.  I need to know if expecting a FileNameEdit to behave the same way as a BitBtn is unrealistic?  Currently, text and image of the 2 BitBtn’s behave the way I want, text and image greyed out when visible and not enabled.

Thanks and wait to hear

tetrastes

  • Hero Member
  • *****
  • Posts: 717
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #6 on: August 14, 2025, 08:56:30 pm »
It seems that this is a problem of your widgetset and/or DE.

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #7 on: August 14, 2025, 11:24:05 pm »
I checked it is the same as the opening post
Sorry for that stupid question... But I still don't understand: You are saying "All four objects are not enabled but are visible.  But the two types of objects respond differently." Which "four objects" - there are many more on the screenshot? Which two respond differently? You mean the buttons "Open the m3u file" and "Append files"? Are you saying that they are disabled? Hard to believe... Which widgetset are you using? Which operating system? Did you change the Font.Color? (Although I am almost 100% sure that there is no widgetset which allows to change the caption color of a disabled control)

Maybe it would help if you'd remove everything unrelated so that only the "four objects" are left and post the remaining project (pack pas, lfm, lpi and lpr files into a zip).

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #8 on: August 15, 2025, 05:07:23 pm »
Dear All

Following quality feedback I have revised the request, done more tests and found that the nature of the problem is different to my earlier post.

Please see openingscreen.pdf.  It shows 4 BitBtns: “Open error messages”, “Calculate Play Time”, “Save”, “Exit”.  When visible and not enabled the icon and the text are greyed out.  They respond as expected when I make them enabled.  The image and the text become bolder.

There are also two FileNameEdits: “Open the m3u file” and “Append file(s)”.  When the form is created the “Open the m3u file”, is enabled and visible (not shown in the picture as I was experimenting) and “Append file(s)”, is not enabled and is visible.

However, “Append file(s)” in its not-enabled state, has text which is not greyed out.  When enabled, the text has the same boldness.

The “Append file(s)” object you see in the image is set to visible but not enabled.  When compared to “Open error messages” which is also visible and not enabled you can see the difference.

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #9 on: August 15, 2025, 05:44:22 pm »
Thanks for the clarification. But I still do not understand: You call "Open the m3u file" and "Append file(s)" "FilenameEdit". And this is what confuses me: TFileNameEdit is a completly different control, a TEdit which has a small button icon at the right (component palette "Misc"), but your control just look like TBitBtn. What is the class type of these two controls?

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #10 on: August 15, 2025, 06:51:21 pm »
Dear All

Thanks.  I do not know what a class type is but a TFileEdit is in the Misc section and is the 7th from left.  I use one to select multiple files (mp3 files whose paths/filename I want added to the memo window, that then gets saved to the playlist file), and I use the other to select one file, the playlist file.  Yes they do look like BitBtns but these are specific for selecting files.  Hope that helps

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #11 on: August 15, 2025, 07:05:38 pm »
Seems that we are talking of the same object. But when I drop a TFileNameEdit on a form it looks like in the attachment: an edit box which has a button at the right side. But your's looks like a TBitBtn. Even when I reduce the width of the TFileNameEdit so that only the button is visible I have no idea how to get the caption text. What are you doing with the TFileNameEdit so that it looks like a TBitBtn? Please post a little project with a simple form and a TFileNameEdit modified like your "Open the m3u file".

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #12 on: August 15, 2025, 07:53:30 pm »
Dear All

Thanks.  I will do that if the following does not help.  Making the space so that a caption appears, is tricky.  You have to play with these settings in the Object Inspector
Button Caption = add your text here
ButtonWidth = 230
Height = 50
Width = 220
This should work

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #13 on: August 15, 2025, 08:17:25 pm »
OK, now I see.

I would not do it this way. I would use a standard TBitBtn for it and drop a TOpenDialog. In the TOpenDialog you can make all the changes that you have in the DialogOptions now. Then add an OnClick-Handler to the TBitBtn which essentially just exeutes the OpenDialog:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnOpen_m3u_FileClick(Sender: TObject);
  2. begin
  3.   with OpenDialog1 do
  4.   begin
  5.     // The following settings can be made in the object inspector directly:
  6.     Filter := 'm3u files (*.m3u)|*.m3u';
  7.     Options := Options + [ofAllowMultiSelect] - [ofEnableSizing];  // You have this in your recent screenshot
  8.     // Execute the dialog
  9.     if Execute then begin
  10.       ... // code that you want to run with the selected OpenDialog1.FileName
  11.     end;
  12.   end;
  13. end;
This way the "Open the m3u file" will exactly look like all the other buttons.

stephanos

  • Jr. Member
  • **
  • Posts: 79
Re: Enabled (and visible) not the same with BitBtn and FileNameEdit
« Reply #14 on: August 16, 2025, 01:02:52 am »
Dear all

Thanks.  I really have to do some sort of formal training.  The solution is as suggested.  I am impressed that something I thought could only be done via a TFileNameEdit button can actually be done via code. That would not have occurred to me and that demonstrates that I have massive knowledge gaps.
I found a simple tutorial because I knew what to search for thanks to the support: https://smartpascal.github.io/help/assets/topendialog.htm
I have started on a solution.  The following brings up a dialog box and I can select a file and behaves as a BitBtn should. 

Code: Pascal  [Select][+][-]
  1. uses
  2.  Dialogs;
  3.  
  4. procedure TForm1.BitBtn2Click(Sender: TObject);  // new append files
  5. var  //
  6.   OpenDialogA: TOpenDialog;
  7.   TheFileNames : string;
  8. begin
  9.      OpenDialogA := TOpenDialog.Create(self);
  10.   OpenDialogA.Execute;
  11.     TheFileNames := OpenDialogA.Files.Text;
  12.   Label3.Caption := TheFileNames;
  13. end;  

 

TinyPortal © 2005-2018