1

I'm writing a component which requires properties of type Date, Time, and Date/Time. I would like these properties to be visible in the Object Inspector, with an option to use a popup property editor.

I have tried TDate as a published property, and this gives me the results I need for just Date alone. However I need the same thing for TTime and TDateTime but they don't come with a property editor, and in fact it won't even accept any value I type in there either.

I have found the TDateTimeProperty which can be used as a property editor, or so I understand anyway. I have done the necessary implementation when registering this component. This property I need to apply it to is actually a TCollectionItem descendant, not necessarily a part of the component but within it.

This is how I'm registering it...

RegisterComponents('My Page', [TMyComponent]);
RegisterPropertyEditor(TypeInfo(TDateTime), TMyCollectionItem, 'MyPropName', TDateTimeProperty);

Although this compiles, when I install it, there is no property editor on this property. I have tried using my component's class name in place of TMyCollectionItem but same issue.

What am I doing wrong here to show this property editor?

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • 1
    if you see your TDateTime value as date/time string in the Object inspector, in fact, the property editor is working. – jachguate Dec 18 '12 at 16:15
  • It acts the same with it as it does without it, but this isn't want I intended. Is this supposed to be an actual date/time picker or is it just a special formatting? – Jerry Dodge Dec 18 '12 at 16:33
  • 1
    Where do you read that it will show a TDateTimePicker? Just look at the TDateTimeProperty implementation in the ToolsAPI\DesignEditors.pas unit!. Since TDateTime is in fact, a Double precision number, if your property shows and accept strings with date/time format, the property editor is working. – jachguate Dec 18 '12 at 16:43
  • I was just expecting something different from what I got, so it is working as it should but not as I was pretty much hoping. – Jerry Dodge Dec 18 '12 at 20:45
  • NOTE: I have answered my question here: http://stackoverflow.com/questions/13944810/how-can-i-implement-my-own-custom-property-editor-for-all-instances-of-a-certain – Jerry Dodge Dec 19 '12 at 03:17

1 Answers1

2

You don't need to register the built-in property editors for TDateTime, TDate and TTime. They are already registered. That's why your attempts to register them have no impact.

The built-in property editors for these types simply convert between the underlying floating point value and a string representation. They don't implement date time pickers or anything like that.

You say:

However I need the same thing for TTime and TDateTime but they don't come with a property editor, and in fact it won't even accept any value I type in there either.

That is in fact incorrect. They do come with property editors. They are the same built-in property editors that you named in your question. And they do accept values. They don't accept the values you provided because you provided invalid values.

If you want to register a property editor that does provide a visual date time picker, then you will have to write the property editor yourself.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thanks, I did make one myself, and since this was a separate question, I answered it myself here: http://stackoverflow.com/questions/13944810/how-can-i-implement-my-own-custom-property-editor-for-all-instances-of-a-certain – Jerry Dodge Dec 19 '12 at 03:18
  • No, I need help fixing my internet from dropping out randomly, but that's entirely different. Thanks! – Jerry Dodge Dec 19 '12 at 08:07