绝地督察没有开火事件吗? [英] Jedi Inspector not firing event?

查看:88
本文介绍了绝地督察没有开火事件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到TJvInspector有一个 OnItemDoubleClicked 事件,我认为这正是我所需要的,因为我需要检测鼠标是否双击了Color Item属性(我想显示自己的颜色表单以允许选择自定义颜色等。

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;

如果我在该事件中将光标设置在任何地方并使用F4运行,甚至在其中设置了断点,不会在运行时明显触发,消息框也不会弹出。

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.

这是Jedi Inspector组件的错误还是已知问题?

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.

推荐答案

通过查看JvInspector代码,当没有项目编辑器(只读?)并且项目是对象属性时,将触发OnItemDoubleClicked。因此,这绝对是错误的事件(它的名称具有误导性)。

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).

问题是双击事件不是针对JvInspector控件,而是针对当前编辑器控件(TEdit,TComboBox等)。因此,JvInspector看不到双击。为了解决这个问题,您需要挂钩编辑器的OnDblClick事件。为此,JvInspector具有OnBeforeEdit事件。

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.

这篇关于绝地督察没有开火事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆