سؤال

I noticed the TJvInspector has a OnItemDoubleClicked event which I thought would be just what I require as I need to detect if the mouse was double clicked on a Color Item property (I want to show my own Color Form to allow selecting custom colors etc).

But I cannot even get the event to fire at all, for example:

procedure TfrmInspector.JvInspector1ItemDoubleClicked(Sender: TObject;
  Item: TJvCustomInspectorItem);
begin
  if Item is TJvInspectorColorItem then
    ShowMessage('you double clicked on a color property')
  else
    ShowMessage('not a color property');
end;

If I set the cursor anywhere in that event and run with F4, or even set a breakpoint there it doesn't trigger so obviously at runtime the message boxes are also not popping up.

Is this a bug or known problem with the Jedi Inspector components?

I don't normally ever use them and just seem to keep running into trouble with them.

هل كانت مفيدة؟

المحلول

By looking at the JvInspector code the OnItemDoubleClicked is fired when there is no item editor (readonly?) and the item is an object property. So this is definitely the wrong event (and its name is misleading).

The problem is that the double click event isn't directed at the JvInspector control but at the current editor control (TEdit, TComboBox, ...). So the JvInspector doesn't see the double click. To solve this you need to hook the editor's OnDblClick event. And for that the JvInspector has the OnBeforeEdit event.

procedure TForm1.JvInspector1BeforeEdit(Sender: TObject; Item: TJvCustomInspectorItem;
  Edit: TCustomEdit);
begin
  TEdit(Edit).OnDblClick := ItemDblClick;
end;

procedure TForm1.ItemDblClick(Sender: TObject);
begin
  ShowMessage(JvInspector1.Selected.Name);
  Abort; // don't change the value by the default double click handler
end;

This doesn't work for "Set" properties or other properties that have no editor control.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top