How do you get the value that has been entered into the JvInspector at runtime?
The Demo in \..\jvcl\examples\JvInspector
shows how to add strings, by writing something like this (extract from the demo):
var
FirstName: string;
implementation
procedure TfrmInspector.AddVarious;
var
InspCat: TJvInspectorCustomCategoryItem;
begin
TJvInspectorVarData.New(InspCat, 'First', TypeInfo(string), @FirstName).DisplayName := 'Copy of first name';
end;
I wanted to add a TColor property so I did this:
var
FirstName: string;
SomeColor: TColor;
implementation
procedure TfrmInspector.AddVarious;
var
InspCat: TJvInspectorCustomCategoryItem;
begin
TJvInspectorVarData.New(InspCat, 'First', TypeInfo(string), @FirstName).DisplayName := 'Copy of first name';
TJvInspectorVarData.New(InspCat, 'SomeColor', TypeInfo(TColor), @SomeColor;
end;
This displays correctly but I cannot seem to get the value that is changed for SomeColor when selecting a new color from the dropdown list in the inspector.
I tried this:
procedure TfrmInspector.JvInspector1ItemValueChanged(Sender: TObject;
Item: TJvCustomInspectorItem);
begin
if (Item.Data <> nil) and (CompareText(Item.Data.Name, 'FirstName') = 0) then
ShowMessage(Item.Data.AsString) //< works
else if (Item.Data <> nil) and (CompareText(Item.Data.Name, 'SomeColor') = 0) then
ShowMessage(ColorToString(TColor(Item.Data))); //< does not return correct value
end;
I don't normally use Jedi components but thought I would give them another chance but there seems to be little documentation, I looked on the Wiki page for OnItemValueChanged event: http://wiki.delphi-jedi.org/wiki/JVCL_Help:TJvInspector.OnItemValueChanged but again barely any information or help.
I am sure instead of trying to get ColorToString(TColor(Item.Data))
I need to use Item.Data.AsVariant
but I could be wrong, when I tried I got AV errors so I probably am totally wrong, nothing I ever do or try seems to work :(