Firebreath c++一些指针的理解
Firebreath C++ some pointer understanding
我在这里问了一个问题,点击鼠标屏幕坐标,得到了一个很好的答案(确认的一个),感谢Gaurav Raj
。在这个示例中:
bool MirrarOrnaments::onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *)
{
if(evt->m_Btn == FB::MouseButtonEvent::MouseButton_Left)
{
/**
* apiPtr is the pointer to FB::JSAPIPtr
* mousePositionCallback is the JSAPI function which takes variant list of mouse
* co-ordinates as argument
*/
apiPtr->invoke("mousePositionCallback", FB::variant_list_of(evt->m_x)(evt->m_y));
}
}
当我得到,最后一个字符串必须运行mousePositionCallback
函数在我的JavaScript与FB::variant_list
参数;但是我不能理解apiPtr指针的目的,我在哪里可以得到它,以及如何这个指针到FB::JSAPIPtr
必须实际上看在我的代码。
FireBreath中的FB::JSAPIPtr类型只是boost::shared_ptr(共享自动指针,因此您不必在对象上调用delete,也不必担心它消失)的方便别名…
尝试添加getRootJSAPI()调用,这应该为您返回apiPtr。
bool MirrarOrnaments::onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *)
{
if(evt->m_Btn == FB::MouseButtonEvent::MouseButton_Left)
{
/**
* apiPtr is the pointer to FB::JSAPIPtr
* mousePositionCallback is the JSAPI function which takes variant list of mouse
* co-ordinates as argument
*/
// if you want to access it from the API Part
// FB::JSAPIPtr apiPtr(boost::make_shared<FBYourPluginAPI>(m_plugin));
//add the next line:
FB::JSAPIPtr apiPtr = m_plugin.lock()->getRootJSAPI();
apiPtr->Invoke("mousePositionCallback", FB::variant_list_of(evt->m_x)(evt->m_y));
}
}
相关文章:
- 1d 智能指针不适用于语法 (*)++
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 为什么使用 "this" 指针调用派生成员函数?
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用指针从C++中的数组中获取最大值
- 助记符和指向成员语法的指针
- 嵌入方指针压缩已禁用
- 数组的指针从不分段故障
- C++ 指针的内存地址和指向数组的内存地址如何相同?
- 何时在引用或唯一指针上使用移动语义
- QMetaObject invokeMethod的基于函数指针的语法
- 如何从 std::atomic 中提取指针 T<T>?
- 如何在 C# 中映射双 C 结构指针?
- C++将浮点指针值舍入为小数位数
- 为什么++(*p)更改指针值
- 调整大小后指向元素值的指针unordered_map有效?
- 正在将指针转换为范围
- 使用指向成员的指针将成员函数作为参数传递
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错