Jedi Inspector not firing event?

孤街浪徒 提交于 2019-12-11 04:16:02

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/14182460/jedi-inspector-not-firing-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!