How to display the custom defined properties in auto completion list

Hallo every one.
I am using the custom properties functionality in order to display and handle a property that i do not want to have it declared as published.
So, far so good.
My problem is that i cannot display this custom property inside auto completion list. What am i doing wrong?
How could i do it? Do you have such an example could display cusytom properties inside auto-completion items?

Dear @CHARALAMPOUS_STEFANOS, it always help if you provide us with detailed information about what are you exactly doing. This way we don't waste time trying to reproduce an issue that might not be exactly the way you are doing it.

So can you please send us a small project reproducing the issue, or at least explaining in details how are you defining such custom properties and what exactly are you trying to do that causes the issue?

Dear Wagner, i thought i had uploaded to you the sample poject. Obviously, i had not and i apologize for that. So find the uploaded project.
Custom Properties.zip (96.7 KB)

After extracting the contents of this zip file, you will find a folder called SavedProjects where you can find a saved project to use as sample for this issue.

The flow to reproduce the issue is

  1. After running the project, you will get prompter to open IDE (picture 1) .

2.After , you must open the project project1 inside folder SavedProjects pictures 2, 3 ). You will see then the unit1 and unit2. Please see the unit2 form in for view . You will see in the object inspector the properrty CustomProps
CustomProps ObjectInspetor

I have implemented a custom property editor called TCustomPropsPropertyEditor ( You will find the declaration and implementation for this inside unit fMain.pas. You can find it inside the project )

implementation
uses

  • VCl.ScriptForm, StringsInspEditor, frmPropsStrings, System.TypInfo;*

*{$R .dfm}

type
TCustomPropsPropertyEditor = class(TPropertyEditor)

  • public*
  • constructor Create(AProp: TProperty); override;*
  • function Execute: Boolean; override;*
  • end;*

function GetCustomProps(AInstance: TPersistent; Prop: TProperty): string;
var

  • FormIntf: IScriptBasedForm;*
  • SValue: string;*
  • Strings: TStringList;*
    begin
  • Result := '0';*
  • if Supports(AInstance, IScriptBasedForm, FormIntf) then*
  •  if FormIntf.GetSaveProps.IndexOfName(Prop.FullName) > -1 then*
    
  •  begin*
    
  •    SValue :=  FormIntf.GetSaveProps.Values[Prop.FullName];*
    
  •    if not assigned(FormIntf.GetSaveProps.Objects[Prop.Index]) then begin*
    
  •       FormIntf.GetSaveProps.Objects[Prop.Index] := TStringList.Create;*
    
  •       TStringList( Prop.AsObject).Text := SValue;*
    
  •    end;*
    
  •    Result := IntToStr(LongInt(FormIntf.GetSaveProps.Objects[Prop.Index]));*
    
  •  end*
    
  •  else*
    
  •  begin*
    
  •    SValue := EmptyStr;*
    
  •    Prop.SetEmulatedOff;*
    
  •    if not assigned(FormIntf.GetSaveProps.Objects[Prop.Index]) then*
    
  •    begin*
    
  •       FormIntf.GetSaveProps.Objects[Prop.Index] := TStringList.Create;*
    
  •       TStringList( Prop.AsObject).Text := SValue;*
    
  •    end;*
    
  •    result :=  LongInt(FormIntf.GetSaveProps.Objects[Prop.Index]).ToString;*
    
  •    Prop.SetEmulatedOn;*
    
  •  end;*
    

end;

procedure SetCustomProps(AInstance: TPersistent; Prop: TProperty; Value: string );
var

  • FormIntf: IScriptBasedForm;*
  • Strings: TStrings;*
    begin
  • if Supports(AInstance, IScriptBasedForm, FormIntf) then begin*
  • if not assigned( FormIntf.GetSaveProps.Objects[Prop.Index]) then*
    
  •    FormIntf.GetSaveProps.Objects[Prop.Index] := TStringList.Create;*
    
  • TStringList( FormIntf.GetSaveProps.Objects[Prop.Index]).Text := Value;*
    
  • FormIntf.GetSaveProps.Values[Prop.FullName] := Value;*
    
  • end;*
    end;

procedure RegisterScriptFormCustomProps;
var

  • FormClass: TScriptFormClass;*
    begin
  • FormClass := DefaultScriptFormClass;*
  • RegisterCustomProperty(FormClass, 'CustomProps', TStrings.ClassInfo , true, GetCustomProps, SetCustomProps);*
    end;

{ TCustomPropsPropertyEditor }

constructor TCustomPropsPropertyEditor.Create(AProp: TProperty);
begin

  • inherited;*
    end;

function TCustomPropsPropertyEditor.Execute: Boolean;
var

  • SParams: string;*
  • propStrings: TPersistent;*
    begin
  • with TfrmPropStrings.Create(nil) do*
    
  • try*
    
  •     propStrings := TStrings(Prop.AsObject);*
    
  •     redStrings.Lines.Assign(propStrings);*
    
  •     Result := ShowModal = mrOK;*
    
  •     if Result then*
    
  •     begin*
    
  •       propStrings.Assign(redStrings.Lines);*
    
  •       TScriptForm(Prop.Instance).SaveProps.Values['CustomProps'] := redStrings.Lines.Text;*
    
  •     end;*
    
  • finally*
    
  •   Free;*
    
  • end;*
    

end;

3.Then trying to display the property CustomProps , i am trying to search for this property inside autocompletionlist inside FormCraete event handler


but as you can see there is no CustomProps.

pict1--run project




Well, you didn't follow my suggestion in Running project with custom properties raises Exception - #4 by wlandgraf?

You are creating a virtual property, thus it's expected it's not displayed in the code completion. It's just a fake property in the object inspector.

Having your own custom scripter class as I suggested not only works but also reduces most of the code to just a few lines. Here is the modified project that works.

CustomProps.zip (6.1 KB)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.