Crate wita[][src]

Expand description

A window library in Rust for Windows.

wita is a library that create a window and run an event loop. It is only for Windows.


struct Application;

impl Application {
    fn new() -> Result<Self, wita::ApiError> {
            .title("hello, world!")

impl wita::EventHandler for Application {
    fn closed(&mut self, _: &wita::Window) {

fn main() {
    wita::run(wita::RunType::Wait, Application::new).unwrap();

Event handling

You must implement EventHandler for the your defined object, and can handle events in the impl EventHandler.

struct Foo {}

impl Foo {
    fn new() -> Result<Self, wita::ApiError> {
        Ok(Self {})

impl wita::EventHandler for Foo {
    // You define handlers.
    // For example, handle the event that closed the window.
    fn closed(&mut self, _: &wita::Window) {
        // write handling codes

Next, pass the your defined object to run.

wita::run(wita::RunType::Wait, Foo::new).unwrap();

Drawing on the window

There are directly no any methods for drawing on a Window in wita. However, a Window provides the raw_handle that return a pointer which is HWND. You can create a drawing context by using the raw_handle such as DirectX, Vulkan, etc.


An IME composition string and a candidate list

Provides raw input data.


Represents an Win32 API error.

Represents the borderless window style.

The object to build a window into the parent window.

A virtual key and a scan code.

Logical coordinate.

Describes monitor info.

A mouse cursor position and pressed mouse buttons.

Physical coordinate.

A generic position

A keyboard scan code

Screen coordinate.

A generic size

Represents a window.

The object to build a window.

Represents a window style.


Describes a icon.

Describes the state of a keyboard key and a mouse button.

Describes mouse buttons.

Describes event loop types.

Describes keyboard key names.


The value is an unit in logical coordinates.


Trait that must implements for handling events.

A window style and the borderless window style.

Converts to a logical position.

Converts to a logical size.

Converts to a physical position.

Converts to a physical size.


Return monitors info.

Get current key states.

A screen position to a monitor.

Run the event loop.

Type Definitions

A position in logical coordinate.

A size in logical coordinate.

A position in physical coordinate.

A size in physical coordinate.

A position in screen coordinate.