> For the complete documentation index, see [llms.txt](https://chaoses-ib.gitbook.io/directory-opus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh-1/onclick.zh.md).

# OnClick

**OnClick** 事件是 [脚本函数](/directory-opus/guan-fang-shou-ce/readme.zh-8/script_functions.zh.md) 的主要入口点。

| **方法名称:**  | OnClick                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **参数类型:**  | [**ClickData**](/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh/clickdata.zh.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| **返回值类型:** | *无*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **描述:**    | <p>当包含 <a href="/directory-opus/guan-fang-shou-ce/readme.zh-8/script_functions.zh.md">脚本函数</a> 的按钮或热键被执行时，此方法被调用。<strong>ClickData</strong> 对象提供了关于命令环境的有用信息，包括源和目标标签和路径、任何选定的文件、命令行参数、任何按下的修饰键等。所有这些信息都可以通过 <strong>ClickData.func</strong> 属性访问（它返回一个 <a href="/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh/func.zh.md"><strong>Func</strong></a> 对象）。<br>请注意，当一个脚本函数被执行时，任何不包含在函数内部的指令都会先执行，然后再调用 <strong>OnClick</strong>。这意味着 <strong>OnClick</strong> 方法在技术上是可选的（因为你可以在函数外部实现整个脚本），尽管建议你实现它仅仅是为了接收 <strong>ClickData</strong> 对象的益处。</p> |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh-1/onclick.zh.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
