获取鼠标屏幕坐标点击 [英] Get mouse screen coordinates on click

查看:214
本文介绍了获取鼠标屏幕坐标点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在用户点击鼠标左键(鼠标点击坐标 - 换句话说)后,我可以获得鼠标屏幕坐标。这是一个用FireBreath写的插件。
我尝试使用:

How can I get mouse screen coordinates right after user clicks left mouse button (mose click coordinates - in another words). It's for a plugin written with FireBreath. I was tryin to use:

FB::variant TestPluginAPI::Detect()
{
POINT pt;

if (WM_LBUTTONUP)
{
    GetCursorPos(&pt);
}
FB::VariantList Dtd = FB::variant_list_of(pt.x)(pt.y);
return Dtd;

它返回JavaScript数组 Dtd c $ c> pt.x 和 pt.y ,然后我使用这个数组通过JS在我的页面上渲染这个坐标。

it's returning JavaScript Array Dtd with pt.x and pt.y in it, then I'm using this array to render this coordinates on my page via JS. This one gives me mouse coords only on page start.

然后我在尝试 WM_LBUTTONUP == MK_RBUTTON in if ;它会给我一些随机的数字...我能做什么?

你能帮我吗?

Then I was trying WM_LBUTTONUP == MK_RBUTTON in if; It gives me some random huge numbers... what can I do?
Will you kindly help me?

推荐答案

如果要在JavaScript函数中获取鼠标位置,可以在插件中创建回调JSAPI函数,并在单击鼠标左键时使用参数FB :: VariantList来调用鼠标坐标。您可以通过在继承自FB :: PluginCore的类中重载onMouseDown事件来检测鼠标单击。要注册onMouseDown活动,您可以在标题中使用以下代码。


BEGIN_PLUGIN_EVENT_MAP()

  EVENTTYPE_CASE(FB :: MouseDownEvent,onMouseDown,FB :: PluginWindow)
END_PLUGIN_EVENT_MAP()

If you want to get mouse position in your javascript function, you can make a callback JSAPI function in your plugin and invoke it when left mouse button is clicked with arguments as FB::VariantList of mouse co-ordinates. You can detect mouse click by overloading the onMouseDown event in the class which inherits from FB::PluginCore. To register onMouseDown event, you can use following code in the header.
BEGIN_PLUGIN_EVENT_MAP()
   EVENTTYPE_CASE(FB::MouseDownEvent, onMouseDown, FB::PluginWindow) END_PLUGIN_EVENT_MAP()

virtual bool onMouseDown(FB :: MouseDownEvent * evt,FB :: PluginWindow *);

virtual bool onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *);

onMouseDown可以定义为: -

bool MirrarOrnaments :: onMouseDown(FB :: MouseDownEvent * evt,FB :: PluginWindow *)

{

onMouseDown can be defined as -
bool MirrarOrnaments::onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *)
{

  if(evt-> m_Btn == FB :: MouseButtonEvent :: MouseButton_Left)

   {

     / ** 0047
      * apiPtr是指向FB :: JSAPIPtr载的指针
      * mousePositionCallback是JSAPI函数,它使用变量列表的小mouse _
      *坐标作为参数

      * /

      apiPtr-> invoke(mousePositionCallback,FB :: variant_list_of(evt-> m_x)(evt-> m_y));

   }

}

   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));
   }
}

希望这是您要询问的。你的问题是模糊的。

Hope this is what you are trying to ask. Your question is kind of vague.

这篇关于获取鼠标屏幕坐标点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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