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

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

问题描述

我在 https:/上的文档/developer.autodesk.com/zh-CN/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;
    }
}

根据我的经验,如果在您的自定义工具之前执行了诸如 handleButtonDown handleButtonUp 之类的句柄函数,并返回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天全站免登陆