appkit.cr
AppKit host for Crystal
require "appkit" exposes scoped AppKit::MetalWindow.open(width, height, title). The window provides poll_events, framebuffer_size, and present(Metal::Texture). It uses backing-pixel dimensions and presents through CAMetalLayer. Calls belong on the process main thread.
This macOS host depends on metal, with no Garnet dependency. A small Objective-C++ bridge is built during shard installation. The Garnet example demonstrates explicit renderer ownership and borrowed native texture presentation. This is not an iOS host.
Input, focus and logical size
poll_events collects native input. Read it with each_event, which yields AppKit::Event values: key down/up/repeat with the macOS virtual key code and Modifiers, mouse down/up/move with button number and content-view position in points (top-left origin), scroll deltas in lines, typed characters, focus changes and pointer exit. Key events are consumed so AppKit doesn't beep.
The title-bar close button sets close_requested? (and poll_events returns false) without closing the window, so the owner controls teardown. logical_size reports the content size in points, scale the backing scale, and focused?/iconified? the window state. wait_events(timeout) sleeps until input arrives. AppKit.clipboard reads and writes pasteboard text. garnet-engine/desktop maps these to Garnet::Input::Devices.
appkit.cr
- 0
- 0
- 0
- 2
- 1
- 1 day ago
- November 30, 2026
MIT License
Wed, 02 Dec 2026 02:09:37 GMT