> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/nativedb-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/nativedb-documentation/classes/inkwidget.md).

# inkWidget

## Description

See [wiki](https://github.com/psiberx/cp2077-codeware/wiki#user-interface) of Codeware to learn more about creating a UI. You should install [RedHotTools](https://github.com/psiberx/cp2077-red-hot-tools/) too. It provides a powerful `InkInspector` tool to help you design a UI while in-game.

## Functions

#### BindProperty(propertyName: CName, stylePath: CName) -> Bool

Bind a style to a property of a widget, based on the current theme of the game. You must define a style resource using \[this.SetStyle], otherwise this function will have no effect.

Example to use the red color of the game on a widget: `BindProperty(n"tintColor", n"MainColors.Red")`.

#### RegisterToCallback(eventName: CName, object: handle:IScriptable, functionName: CName) -> Void

You need to setup your widget to listen for events and trigger callbacks. You can do so using \[this.SetInteractive] on the widget.

You can listen to the following common events (see also the [full list](https://github.com/psiberx/cp2077-cet-kit/blob/f64c837e589ffffc030e79ed0123688eb3091098/EventProxy.lua#L28)):

* `n"OnEnter"`: when cursor enters the widget (hover in)
* `n"OnLeave"`: when cursor leaves the widget (hover out)
* `n"OnPress"`: when mouse left button is pressed inside the widget
* `n"OnRelease"`: when mouse left button is released inside the widget

You must declare your callback method with `cb` qualifier, and with one argument of type ref<\[inkPointerEvent]>.

#### SetStyle(styleResPath: redResourceReferenceScriptToken) -> Void

You must define an `.inkstyle` file to use \[this.BindProperty]. When you add a widget with a script, this call is required on each widget you create.

A common `styleResPath` used to define colors is: `r"base\\gameplay\\gui\\common\\main_colors.inkstyle"`. You can see a Json representation of this file on [Discord](https://discord.com/channels/717692382849663036/1036574451237662780/1287833757449060444).

You can find other styles using WolvenKit.


---

# 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://wiki.redmodding.org/nativedb-documentation/classes/inkwidget.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.
