darwin

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for darwin/amd64

Overview

Package darwin implements the macOS backend (AppKit + WKWebView) in pure Go: Objective-C is driven through the runtime with purego, no cgo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableNotificationSenders

func EnableNotificationSenders()

EnableNotificationSenders registers the opt-in translator before a sender notification can reach the backend. Later constructors only read the Once.

func TestAccessibilityAttribute

func TestAccessibilityAttribute(handle uintptr, label, attr string) (value string, settable, named, ok bool)

TestAccessibilityAttribute reads an attribute of the element labeled label through AppKit's older API, as assistive technology does: its value, whether it is settable, and whether the element names it.

func TestAccessibilityPerform

func TestAccessibilityPerform(handle uintptr, label, action, value string) bool

TestAccessibilityPerform performs action ("press", "increment", "decrement", "focus" or "value" with value) on the element of a window showing native UI labeled label, as assistive technology does, and reports whether there was such an element that allowed it.

func TestAppClick

func TestAppClick(handle uintptr, x, y float64)

TestAppClick is TestClick through the application's event queue, where event monitors see the click as they see the user's, as those of transient popovers that close on clicks elsewhere. The application has handled the click when it returns (handlePosted).

func TestAppKey

func TestAppKey(code uint16, chars string)

TestAppKey posts a key down and up to the application's event queue, which sends it to the key window as it does the user's keys, to a page or native UI. The application has handled the key when it returns (handlePosted).

func TestAppPress

func TestAppPress(handle uintptr, x, y float64, down bool)

TestAppPress is half of TestAppClick: the left mouse down, or the up, which a user's click handles apart, a frame or more later.

func TestClick

func TestClick(handle uintptr, x, y float64)

TestClick sends a left mouse down and up at a point of a window's content (top-left origin, in points), like a user click.

func TestClickAndType

func TestClickAndType(handle uintptr, x, y float64, text string) bool

TestClickAndType clicks (x, y) in a window showing native UI and types text there at once, before the window draws another frame, with key events that go through the input method as a keyboard's do. It reports false for a window showing a web page, and while the input source is an input method, which would compose the keys rather than insert them.

func TestCollectionBehavior

func TestCollectionBehavior(handle uintptr) uint

TestCollectionBehavior returns a window's NSWindowCollectionBehavior.

func TestCompose

func TestCompose(handle uintptr, text string, caret int, commit bool) bool

TestCompose does what an input method does to a window showing native UI: it shows text as the composition, its caret at rune caret, or with commit, inserts it. It reports false for a window showing a web page.

func TestComposeOver

func TestComposeOver(handle uintptr, text string, caret int, commit bool, from, length int) bool

TestComposeOver is TestCompose replacing the length UTF-16 units of the input method's document at from, unless from is negative, as macOS's press and hold does with the letter it accents.

func TestControlClick

func TestControlClick(handle uintptr, x, y float64)

TestControlClick Control-clicks (x, y), in points from the top-left corner of a window's content.

func TestDockInspector

func TestDockInspector(handle uintptr) bool

TestDockInspector opens the web inspector of a window docked to it, and reports whether the window has one.

func TestDockMenu

func TestDockMenu(click int) []string

TestDockMenu returns the titles of the Dock menu the app delegate returns, and clicks the item at click unless it is -1.

func TestDockTileImage

func TestDockTileImage() []byte

TestDockTileImage renders the content of the Dock tile offscreen, as the Dock does, to PNG; nil when the tile shows the plain application icon.

func TestDocumentChrome

func TestDocumentChrome(handle uintptr) (title, file string, icon, edited bool)

TestDocumentChrome describes what a window's title bar shows of its document: the title, the file of the proxy icon, whether the icon shows, and the dot of an edited document.

func TestDrag

func TestDrag(handle uintptr, points [][2]float64)

TestDrag presses the primary button at the first of points, in points from the top-left corner of a window's content, drags the pointer through the others, and releases it at the last.

func TestDropData

func TestDropData(handle uintptr, x, y float64, data transfer.Data, operations transfer.Operation) (operation transfer.Operation, dropped bool)

TestDropData exercises native source pasteboard providers and the destination protocol with serialized data (no core session token).

func TestDropFiles

func TestDropFiles(handle uintptr, x, y float64, paths []string) (over, dropped bool)

TestDropFiles drags files over (x, y), in points from the top-left corner of a window's content, and drops them there, as Finder would: it calls the surface's dragging methods with an NSDraggingInfo of its own, and puts on the pasteboard the file reference URLs of the files that exist at those paths, with no symbolic links. It reports whether the surface took the files over that point and whether it took the drop.

func TestEndSheet

func TestEndSheet(handle uintptr) bool

TestEndSheet ends the sheet attached to a window as if its first button was clicked, and reports whether there was one.

func TestEndSheetButton

func TestEndSheetButton(handle uintptr, i int) bool

TestEndSheetButton ends the alert attached to a window as a sheet as if its button i, in the order the alert was given them, was clicked.

func TestFullScreenHidesToolbar

func TestFullScreenHidesToolbar(handle uintptr) bool

TestFullScreenHidesToolbar reports whether a window asks to hide its toolbar with the menu bar when it enters full screen.

func TestInputClient

func TestInputClient(handle uintptr) (selected [2]int, document string)

TestInputClient returns what a window's surface tells input methods: the selected range and the whole text of their document.

func TestInspectorPlace

func TestInspectorPlace(handle uintptr) string

TestInspectorPlace reports where the docked inspector of a window is: "content" in its content view, "frame" elsewhere in the window, "" when the window has none.

func TestIsFrontmost

func TestIsFrontmost() bool

TestIsFrontmost reports whether the application is the frontmost one, which NSApp's isActive does not tell while a nonactivating panel is the key window: it reports the app active then.

func TestKey

func TestKey(handle uintptr, code uint16, chars string) bool

TestKey presses and releases the key of virtual key code code, typing chars, in a window showing native UI, as the keyboard does: the events go through the window to its first responder, the surface and its input method or a web view.

func TestKeyShift

func TestKeyShift(handle uintptr, code uint16, chars string, shift bool) bool

TestKeyShift is TestKey with Shift held when shift is set.

func TestObserve

func TestObserve(handle uintptr) (stop func())

TestObserve has key-value observing watch the view of a window showing native UI and the elements of it that assistive technology reads, as other code may: the runtime gives each a generated subclass of its class, whose methods reach the overrides of Golet's classes. stop ends it.

func TestOnScreen

func TestOnScreen(handle uintptr) bool

TestOnScreen reports whether some of a window shows on screen, as the window server reports once it put the window there.

func TestPageKeyShift

func TestPageKeyShift(handle uintptr, code uint16, chars string, shift bool) bool

TestPageKeyShift presses a key in a window showing a web page, which the window sends to its first responder as it does the keyboard's, with Shift held when shift is set. It reports false for a window without a page.

func TestPerformKeyEquivalent

func TestPerformKeyEquivalent(key string, shift bool) bool

TestPerformKeyEquivalent sends a key press with the Command key (and shift when requested) to the application menu and reports whether an item handled it.

func TestPerformMenuItem

func TestPerformMenuItem(path ...string) error

TestPerformMenuItem activates an item of the application menu, found by the titles along its path, e.g. TestPerformMenuItem("File", "New").

func TestRecentDocuments

func TestRecentDocuments() []string

TestRecentDocuments returns the paths of the documents the app recorded with App.AddRecentDocument and did not clear, in the order the system keeps them.

func TestSetDroppedFiles

func TestSetDroppedFiles(handle uintptr, paths []string)

TestSetDroppedFiles makes paths the files of the next drop on a window's page, as if they had been dragged there.

func TestSetWindowAppearance

func TestSetWindowAppearance(handle uintptr, dark bool)

TestSetWindowAppearance gives a window its own dark or light appearance, apart from the application's.

func TestSheet

func TestSheet(handle uintptr) (texts, buttons []string, ok bool)

TestSheet returns the texts of the alert attached to a window as a sheet, and its button titles in the order the alert was given them (their tags), which TestEndSheetButton takes.

func TestSideButton

func TestSideButton(handle uintptr, back bool) bool

TestSideButton presses and releases a mouse's back or forward button (buttons 3 and 4) in a window showing native UI.

func TestTabFocusesLinks(handle uintptr) bool

TestTabFocusesLinks reports whether Tab reaches links and form controls that are not text fields in a window's page.

func TestTrafficLights

func TestTrafficLights(handle uintptr) (x, y float64)

TestTrafficLights returns where the top-left corner of a window's close button is, in points from the top-left corner of the window.

func TestWebViewAttached

func TestWebViewAttached(handle uintptr) bool

TestWebViewAttached reports whether a window's web view is in its view hierarchy.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is the macOS implementation of platform.Backend.

func New

func New() *Backend

New creates the macOS backend.

func (*Backend) App

func (b *Backend) App() platform.AppController

func (*Backend) Applications

func (b *Backend) Applications() ([]platform.Application, error)

Applications finds the .app bundles in the folders apps are installed in and those one level down (Utilities, an app's folder), without looking inside bundles, and Finder (which is in CoreServices), each once: an app a symbolic link points to, as /Applications/Safari.app does, is listed at the link, which FileIcon draws without the badge of links. Each has the name Finder shows (localized, without .app) and its bundle identifier, or its path without one.

func (*Backend) Clipboard

func (b *Backend) Clipboard() platform.Clipboard

func (*Backend) Dialogs

func (b *Backend) Dialogs() platform.Dialogs

func (*Backend) Init

func (*Backend) IsMainThread

func (b *Backend) IsMainThread() bool

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) Network

func (b *Backend) Network() platform.Network

func (*Backend) NewFileWatch

func (*Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)

func (*Backend) NewTray

func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)

func (*Backend) NewWindow

func (*Backend) NotificationsSupported

func (b *Backend) NotificationsSupported() bool

func (*Backend) PopupMenu

func (b *Backend) PopupMenu(m *platform.Menu, pw platform.Window, pos *platform.Point)

func (*Backend) Power

func (b *Backend) Power() platform.Power

func (*Backend) Quit

func (b *Backend) Quit()

func (*Backend) RegisterHotkey

func (b *Backend) RegisterHotkey(hid int, acc string) error

func (*Backend) RemoveAllNotifications

func (b *Backend) RemoveAllNotifications()

func (*Backend) RemoveNotification

func (b *Backend) RemoveNotification(ident string)

func (*Backend) ReplaceFile

func (*Backend) ReplaceFile(target, replacement string) error

ReplaceFile replaces target with -[NSFileManager replaceItemAtURL:withItemAtURL:…], NSDocument's safe save: the target keeps its permissions, creation date, extended attributes (Finder tags, Finder info) and ACLs, and its identity, so that aliases still find it.

func (*Backend) Run

func (b *Backend) Run() error

func (*Backend) Screen

func (b *Backend) Screen() platform.Screen

func (*Backend) Secrets

func (b *Backend) Secrets() platform.Secrets

func (*Backend) SetApplicationMenu

func (b *Backend) SetApplicationMenu(m *platform.Menu)

func (*Backend) Shell

func (b *Backend) Shell() platform.Shell

func (*Backend) ShowNotification

func (b *Backend) ShowNotification(n *platform.Notification, done func(error))

func (*Backend) Signal

func (b *Backend) Signal()

func (*Backend) Step

func (b *Backend) Step()

func (*Backend) Theme

func (b *Backend) Theme() platform.Theme

func (*Backend) UnregisterHotkey

func (b *Backend) UnregisterHotkey(hid int)

func (*Backend) UpdateMenuItem

func (b *Backend) UpdateMenuItem(it *platform.MenuItem)

func (*Backend) Wake

func (b *Backend) Wake()

Wake makes a pending Step return. It is called from any goroutine.

func (*Backend) WebViewAvailable

func (b *Backend) WebViewAvailable() bool

WebViewAvailable reports whether a window showing a web page can have one. WKWebView is part of macOS, so this holds wherever the app runs.

type NSPoint

type NSPoint struct{ X, Y float64 }

NSPoint, NSSize and NSRect mirror the CoreGraphics structs (64-bit).

type NSRect

type NSRect struct {
	Origin NSPoint
	Size   NSSize
}

type NSSize

type NSSize struct{ Width, Height float64 }

type TestAccessNode

type TestAccessNode struct {
	Role, Subrole, Label, Value string
	// Frame is in points of the screen, its origin at the bottom left.
	Frame    [4]float64
	Focused  bool
	Depth    int
	Children int
	// contains filtered or unexported fields
}

TestAccessNode is an element of native UI as assistive technology reads it through NSAccessibility.

func TestAccessibility

func TestAccessibility(handle uintptr) []TestAccessNode

TestAccessibility reads the elements of a window showing native UI as assistive technology does, depth first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL