property description

Issue #121 new
Former user created an issue

When try porting a code from EWB to Smart, there is an non delphish keyword called "description" used in properties. Is there any similiar in DWScript?

      published
         property DataSet: TDataSet read FDataSet write SetDataSet
            description 'Specifies the dataset that the control is bound to'
            reference;
         property OnDataChanged: TDataRowEvent read FOnDataChanged write FOnDataChanged
            description 'Fired when the attached dataset''s data changes, either due to column modifications or scrolling';

Comments (6)

  1. Eric Grange repo owner

    No direct equivalent, is there a spec about that keyword if support for it were to be added? Also what purpose does the 'reference' qualifier serve?

  2. Warley Alex Camargo

    The description clause is optional in properties. It works like it were "Hints". At the objector inspector, when we select the DataSet property, for instance, it will show at the status bar a description 'Specifies the dataset that the control is bound to'

    The reference qualifier, is also optional used in properties. You can have properties directly reference descriptions. This helps to further hide the implementation "descriptions" in properties on the inherited classes, for instance: some components (TEdit, TGrid, TMemo) we have to inform the DataSet property. When we drop a TEdit component on the form, and we select the property DataSet, it shows a description to the dataset Specifies the dataset that the control is bound to'. Because this property is declared in the published scope in an ancestor class.

    TBindableControl = class(TControl)
      private
         FDataSet: TDataSet;
         procedure SetDataSet(Value: TDataSet);
      protected
         property DataSet: TDataSet read FDataSet write SetDataSet
            description 'Specifies the dataset that the control is bound to'
            reference;
    end;
    
    
    TGridControl = class(TBindableControl)
      private
         //..
         function GetColumn(AIndex: Integer): TGridColumn;
         function GetColumn(const AName: String): TGridColumn;
    
      protected
         //..
      public
         // ...
         property Columns[AIndex: Integer]: TGridColumn read GetColumn;
         property Columns[const AName: String]: TGridColumn read GetColumn;
         // ...
      end;
    
    
    TGrid = class(TGridControl)
      protected
         function GetInterfaceClassName: String; override;
      published
         //...
         property DataSet;
    
         property OnShow;
         property OnHide;
         property OnMove;
         // ...
      end;  
    

    It will really cool if DWScript support property overloading More details, see at Properties

  3. Eric Grange repo owner

    Thanks for the description!

    I am not sure to understand the 'reference' though, does it mean that the description is inheritable, whereas if you did not specify 'reference', the description is not inherited? So in your snippet, if we remove the 'reference' from TBindableControl property, then the TGrid.DataSet property will have no description?

    Also, how does this play with property overloading? how are multiple properties with different descriptions handled?

  4. Warley Alex Camargo

    Exactly, the reference clause determine if the description should be streammed of not. dataset.jpg

    The default clause specifies the default value for a property, and is optional. This default value is used to determine if the property should be streamed or not. If a default value is not provided for a property, and the property is published, then it will always be streamed when an instance of the owner class is streamed.

    The description clause specifies the description for a property, and is also optional. This description appears in the Elevate Web Builder IDE's Object Inspector when the property is declared in the published scope, or is promoted to the published scope in an ancestor class.

    The terminating default clause is different from the default value clause above. It is used to specify default array properties and default event properties. See below for more information on default array properties. A default event property is used by the Elevate Web Builer IDE to determine which event handler should be created when a developer double-clicks on a control in the form designer.

             property OnChange: TNotifyEvent read FOnChange write FOnChange
                description 'Fired when the control''s value is modified'; default;
    
             property OnClick: TNotifyEvent read FOnClick write FOnClick
                description 'Fired when the control is clicked'; default;
    

    See some classes declarations See more about property overloading

    I'll try to bypass the property overloading, and using the method overloading idea in SMS, but the nice thing about using published property is the visual look you have on the objector inspector in the EWB.

  5. Eric Grange repo owner

    Exactly, the reference clause determine if the description should be streamed of not.

    Hmmm, I still do not understand, isn't it the "default" clause that determines if a property is streamed or not?

    I am still not clear on what the "reference" qualifier does :/

  6. Log in to comment