TTMSFMXColorPicker

The color picker doesn't seem to restore values from the Ini file that have been saved unless it happens to match a color constant.  I have set the Mode = csmExtendedMore and it saves the values fine like this in the INI:


clBackground=#FFED9C4F

But when it is restored SelectedColor = Null.

Am I missing an important setting?

Hi, 


How are you saving the colors, can you provide us with a sample that is able to reproduce this?
Please note that the selected color is based on the items in the collection, so if the color is not found, the selected color will not be set.

Kind Regards, 
Pieter
  SettingsF := IncludeTrailingPathDelimiter(GetHomePath) + IncludeTrailingPathDelimiter(CompanyName) + ChangeFileExt(AppName, '.ini');
  if ForceDirectories(ExtractFilePath(SettingsF)) then
  begin
    Ini := TIniFile.Create(SettingsF);
    try
      // foreground and background
      Ini.WriteString('DefaultColors', 'clForeground', AlphaColorToString(CEditForeground.SelectedColor));
      Ini.WriteString('DefaultColors', 'clBackground', AlphaColorToString(CEditBackground.SelectedColor));
...
finally
  Ini.Free;
end;

Restoring just reads the AlphaColor back.  It works with standard colors, but what is the point of having Mode = csmExtendedMore if it can't ever use the custom colors?

Are you saying that I must somehow add these custom colors into the collection for it to recognize it?  That doesn't seem very user friendly.  I would think that if it can write clBackground=#FFED9C4F to the ini file that it should be able to read it back again.

Can you also post your code that you use to reload the saved colors?


Kind Regards, 
Pieter
  SettingsF := IncludeTrailingPathDelimiter(GetHomePath) + IncludeTrailingPathDelimiter(CompanyName) + ChangeFileExt(AppName, '.ini');
  if ForceDirectories(ExtractFilePath(SettingsF)) then
  begin
    Ini := TIniFile.Create(SettingsF);
    try
      // foreground and background
      CEditForeground.SelectedColor := StringToAlphaColor(Ini.ReadString('DefaultColors', 'clForeground', AlphaColorToString(CEditForeground.SelectedColor)));
      CEditBackground.SelectedColor := StringToAlphaColor(Ini.ReadString('DefaultColors', 'clBackground', AlphaColorToString(CEditBackground.SelectedColor)));
...
finally
  Ini.Free
end;

Thank you for your feedback, 


We have investigated this here and have applied a fix for this issue.
The next version will address this.

Kind Regards, 
Pieter

Thanks!


Estimated release date?

We will release an update this week.


Kind Regards, 
Pieter

It appears that this bug which was corrected a while back has been reintroduced in version 3.1.0.0

Hi, 


We have retested this here but we are unable to reproduce this. Can you perhaps send us a sample that is able to reproduce this issue so we can investigate this here.

Kind Regards, 
Pieter

I am unable to select custom colors in the color picker and have them show.  There is no code involved.  Whatever is happening is at the IDE level.

I think I see the problem.  If one first selects one of the standard colors, then overrides it with a custom color then it will show.  However, it doesn't show the custom colors from the ini file.  The code for this is the same as the above code as I have not changed it in the past 4 months.

Hi, 


We need to try and reproduce this under the same circumstances with the custom colors loaded.
In the past we were able to detect the issue, and it could be possible that there is an additional shortcoming, but as we are not able to reproduce this here it is important to have a sample that demonstrates this so we can point out the issue and find a solution.

Kind Regards, 
Pieter

I think the problem is ini file corruption with lost settings on my end.  However I'm still not able to set a new custom color without first setting a standard color.  The color boxes are null due to this corruption when they are initialized.  Shouldn't one be able to go from no color setting to a custom color?

I'm still having an issue with some color edits showing up blank as shown by this image:


screen shot



The ini file looks like this:

clPluto=clMaroon
clNeptune=$00993333
clUranus=$00003399
clSaturn=$00333333
clJupiter=$00CC99FF
clMars=$000099FF
clVenus=$00FFCC00
clMercury=clTeal
clMoon=$00996666
clSun=$0000CCFF

The code to read it is very simple...

      CEditSun.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clSun', AlphaColorToString(CEditSun.SelectedColor)));
      CEditMoon.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clMoon', AlphaColorToString(CEditMoon.SelectedColor)));
      CEditMercury.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clMercury', AlphaColorToString(CEditMercury.SelectedColor)));
      CEditVenus.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clVenus', AlphaColorToString(CEditVenus.SelectedColor)));
      CEditMars.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clMars', AlphaColorToString(CEditMars.SelectedColor)));
      CEditJupiter.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clJupiter', AlphaColorToString(CEditJupiter.SelectedColor)));
      CEditSaturn.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clSaturn', AlphaColorToString(CEditSaturn.SelectedColor)));
      CEditUranus.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clUranus', AlphaColorToString(CEditUranus.SelectedColor)));
      CEditNeptune.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clNeptune', AlphaColorToString(CEditNeptune.SelectedColor)));
      CEditPluto.SelectedColor := StringToAlphaColor(Ini.ReadString(RegKey, 'clPluto', AlphaColorToString(CEditPluto.SelectedColor)));

The ones that show correctly have color constants (clMaroon, clTeal), but the others are hex numeric values.  Is there a problem with using StringToAlphaColor?

I think I know what the problem is.  I wanted to save time and used the windows registry to create an ini file with colors for FMX, but that won't work even after I added the alpha channel.  I have several color sets that match the VCL Styles.  What I really need is a pixel copy and paste to speed up this process since it can't be done with this hack.  Sorry for the trouble...

Hi, 


VCL uses TColor which does not contain the alpha channel.
FireMonkey uses TAlphaColor which uses the alpha channel.
The reason you are seeying transparent colors is that the alpha channel is 00.

You can convert VCL colors with MakeColor function that has parameters for R, G and B that can be extracted from the ini file.

Kind Regards, 
Pieter

I thought 00 was opaque or black in VCL.  Thanks.  I had forgotten that I had done this with the registry last March.