伪造工具 handleButtonDown 和 handleButtonUp 函数没有被调用 [英] Forge tool handleButtonDown and handleButtonUp functions not getting called

查看:22
本文介绍了伪造工具 handleButtonDown 和 handleButtonUp 函数没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://forge.autodesk.com/blog/custom-window-selection-forge-viewer-part-iii 位于 https://github.com/Autodesk-Forge/forge-rcdb.nodejs/blob/master/src/client/viewer.components/Viewer.Extensions.Dynamic/Viewing.Extension.SelectionWindow/Viewing.Extension.SelectionWindow.Tool.js 以及 https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/toolinterface/ --- 这些函数中的大部分都被正确调用在我的工具中,例如 handleSingleClick、handleMouseMove、handleKeyDown 等,但其中两个没有被击中——handleButtonDown 和 handleButtonUp.我使用的是 3.3.x 版查看器,但我已更新为使用 4.0.x 版,我认为这可能有助于解决问题,但在两个版本中都会出现相同的问题.感谢您的帮助.

I was looking at the sample code for the tutorial at https://forge.autodesk.com/blog/custom-window-selection-forge-viewer-part-iii which is located at https://github.com/Autodesk-Forge/forge-rcdb.nodejs/blob/master/src/client/viewer.components/Viewer.Extensions.Dynamic/Viewing.Extension.SelectionWindow/Viewing.Extension.SelectionWindow.Tool.js as well as the documentation at https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/toolinterface/ --- Most of these functions are getting called properly in my tool such as handleSingleClick, handleMouseMove, handleKeyDown, and so on, but two of them are not getting hit -- handleButtonDown and handleButtonUp. I was using viewer version 3.3.x but I have updated to use 4.0.x thinking that that might help to resolve the problem, but the same issue occurs in both versions. Thanks for any help.

推荐答案

以下代码块来自Autodesk.Viewing.ToolController#__invokeStack()_toolStack代表ToolController中的激活工具,method代表以handle开头的回调函数,即handleSingleClick、handleMouseMove、handleKeyDown、handleButtonDown、handleButtonUp等.

The following code block from theAutodesk.Viewing.ToolController#__invokeStack(), _toolStack stands for activated tools in the ToolController, the method stands for callback functions started with handle, i.e. handleSingleClick, handleMouseMove, handleKeyDown, handleButtonDown, handleButtonUp, etc.

for( var n = _toolStack.length;  --n >= 0;  )
{
    var tool = _toolStack[n];

    if( tool[method] && tool[method](arg1, arg2) )
    {
        return true;
    }
}

根据我的经验,如果有handleButtonDownhandleButtonUp之类的句柄函数在你的自定义工具之前执行并返回true,那么你的句柄将永远不会被调用.

Based on my experience, if there is a handle function such as handleButtonDown or handleButtonUp executed before your custom tools' and returned true, then your handles will never be called.


幸运的是,Forge Viewer (v3.2) 开始为 ToolController 中注册的自定义工具调用优先级机制.ToolController 将使用优先级编号对其中的工具进行排序,每个工具的优先级编号默认为 0.您可以像这样覆盖优先级以使您的工具在其他工具之前被命中,添加一个函数 getPriority() 以返回大于 0 的数字:


Fortunately, Forge Viewer (v3.2) starts invoking a priority mechanism for custom tools registered in ToolController. ToolController will use the priority number to sort the tools in it, and the priority number of each tool is 0 by default. You can override the priority to make your tools be hit before other tools like this way, to add a function getPriority() to return a number greater than 0:

this.getPriority = function() {
   return 100;
};

这篇关于伪造工具 handleButtonDown 和 handleButtonUp 函数没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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