2

I am using JvInspector to allow editing of the properties of my class. TColor properties show up as 'clRed' etc in the JvInspector editor and are happy to accept similarly entered color names. I really want the same functionality as appears alongside TFont where there is an ellipsis button which opens TFontDialog - for a TColor property I'd like a TColorDialog (or one of my own). I see how the JvInspector has declared TJvInspectorFontItem with a specific edit but I cant figure out how to tell the inspector to come to me for TColor editing - I was expecting to see a register to which I could add my TColor type and my new edit functionality.

A workaround taken from this SO question as follows give me 'on click' functionality that I could use to open a TColorDlg but its not intuitive for the user and not as nice as the ellipsis button solution.

procedure TSimpleMainForm.ItemClick(ASender: TObject);
begin
 ShowMessage(JvInspector1.Selected.Name);  // << my edit would go here
  Abort; // don't change the value by the default double click handler
end;

procedure TSimpleMainForm.JvInspector1BeforeEdit(Sender: TObject;
  Item: TJvCustomInspectorItem; Edit: TCustomEdit);
begin
  TEdit(Edit).OnClick := ItemClick;

end;

Can anyone help or point me at suitable documentation? Thanks

Community
  • 1
  • 1
Brian Frost
  • 12,964
  • 10
  • 72
  • 146

1 Answers1

1

This article has some nice how to examples http://www.neugls.info/the-tjvinspector-component-of-jvcl/

Under the sub title How to make your own item there is a code example for a color dialog.

energ1ser
  • 2,353
  • 3
  • 20
  • 31