Skip to main content

KTool

kds-plugin-document / Exports / KTool

Interface: KTool

酷大师插件自定义工具 实现此接口,即可接受酷大师的各种键盘和鼠标事件,从而创建出一个像酷大师内置工具一样的自定义工具

The KTool class is the interface that you implement to create a KuDaShi tool. To create a new tool, you must define a new class that implements all the methods of the KTool class. Once you have defined a tool class, you select that tool by creating an instance of it and activating it by the app.activateCustomTool method.

Table of contents

Methods

Methods

allowUsingInference

allowUsingInference(): boolean

允许使用吸附行为的回调函数 如果此函数返回 true, 则酷大师的默认吸附行为将被打开

The method used to set whether to use the inference. It is called by KuDaShi when the tool is activated or the user presses a key on the keyboard or moves the mouse.

Returns

boolean

True if using the inference, else false.

Defined in

api.d.ts:4198


onKeyDown

onKeyDown(event): void

按键按下响应函数

The method is called by KuDaShi when the user presses a key on the keyboard.

Parameters

NameTypeDescription
eventKKeyBoardEventIt describes a user interaction with the keyboard.

Returns

void

Defined in

api.d.ts:4208


onKeyUp

onKeyUp(event): void

按键抬起响应函数

The method is called by KuDaShi when the user releases a key on the keyboard.

Parameters

NameTypeDescription
eventKKeyBoardEventIt describes a user interaction with the keyboard.

Returns

void

Defined in

api.d.ts:4218


onLButtonDbClick

onLButtonDbClick(event, inferenceResult?): void

鼠标左键双击响应函数

The method is called by KuDaShi when the user double clicks with the left mouse button.

Parameters

NameTypeDescription
eventKMouseEventIt describes a user interaction with the mouse.
inferenceResult?KInferenceResultThe inference result if Using inference, else undefined.

Returns

void

Defined in

api.d.ts:4187


onLButtonUp

onLButtonUp(event, inferenceResult?): void

鼠标左键抬起响应函数

The method is called by KuDaShi when the left mouse button is released.

Parameters

NameTypeDescription
eventKMouseEventIt describes a user interaction with the mouse.
inferenceResult?KInferenceResultThe inference result if Using inference, else undefined.

Returns

void

Defined in

api.d.ts:4165


onMouseMove

onMouseMove(event, inferenceResult?): void

鼠标移动事件响应函数

The method is called by KuDaShi whenever the mouse is moved.

Parameters

NameTypeDescription
eventKMouseEventIt describes a user interaction with the mouse.
inferenceResult?KInferenceResultThe inference result if Using inference, else undefined.

Returns

void

Defined in

api.d.ts:4154


onRButtonUp

onRButtonUp(event, inferenceResult?): void

鼠标右键抬起响应函数

The method is called by KuDaShi when the right mouse button is released.

Parameters

NameTypeDescription
eventKMouseEventIt describes a user interaction with the mouse.
inferenceResult?KInferenceResultThe inference result if Using inference, else undefined.

Returns

void

Defined in

api.d.ts:4176


onToolActive

onToolActive(): void

工具激活响应函数

The method is called by KuDaShi when the tool is activated.

Returns

void

Defined in

api.d.ts:4123


onToolDeactive

onToolDeactive(): void

工具反激活响应函数 The method is called by KuDaShi when the tool is deactivated.

Returns

void

Defined in

api.d.ts:4131


onToolRetract

Optional onToolRetract(): Object

工具撤销回调函数。当用户点击鼠标右键,或者键盘上的 ESC 键的时候,会调用这个回调函数 如果自定义工具没有实现这个回调函数,那么系统会直接关闭自定义工具

This is an optional callback to retract the KTool from one status to a previous status. It is called when user clicks RMB or presses ESC key. If the tool does not implement this callback, then system will close the tool directly without ask when user click RMB.

Returns

Object

Return an object which contains the retraction result and a flag about whether all the tool steps were retracted and the tool is ready to exit. If that return flag is false, then it means the tool was retracted but it has multiple steps and still in one of the steps.

NameType
readyToExitboolean
retractedboolean

Defined in

api.d.ts:4143