addMouseListener 不适用于 juce::TreeView
我从JUCE的官方论坛没有得到答案,我试图在这里询问并希望。
这是我的问题:
我想将 mouseDoubleClick 事件注册/挂钩到 juce::TreeView 类或其派生类。
void MainComponent::mouseDoubleClick (const MouseEvent &e)
{
//
// do something here
}
MainComponent::MainComponent(....)
{
tv = new TreeView();
addAndMakeVisible( tv );
addMouseListener(this, false);
}
上面的代码不起作用,JUCE 创建者也没有给出答案。我的问题是如何让它发挥作用?应该能够用简单的例子来解释。 addMouseListener() 会不一致,应该记录下来,例如“addMouseListener 不适用于某些类,例如 TreeView”。我很乐意在文档中找到它并避免使用以前的技术。
I got no answer from the official forum of JUCE and I am trying to ask here and hope.
Here is my problem:
I want to register/hook a mouseDoubleClick event to juce::TreeView class or it's derivation.
void MainComponent::mouseDoubleClick (const MouseEvent &e)
{
//
// do something here
}
MainComponent::MainComponent(....)
{
tv = new TreeView();
addAndMakeVisible( tv );
addMouseListener(this, false);
}
The code above doesn't work and no answer from the JUCE creator. My question is how to make it work? It should be able to be explained in simple example. The addMouseListener() would be inconsistent and it should be documented such as "addMouseListener will not work on some classes such as TreeView". I will be happy to find it on the documentation and avoid using previous techniques.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很抱歉迟到的答案,但是...记录一下:
您在这里所做的是将 MouseListener 添加到您的主组件,并告诉它不要将事件转发给它的子组件(第二个参数 == false),所以行为很正常。
恕我直言,如果你写的是:
Sorry for the late answer, but...for the record :
What you're doing here is adding a MouseListener to your main component, and telling it not to forward the events to it's children (2nd param == false), so the behaviour is pretty normal.
IMHO it should work if you wrote instead :