Documentation
¶
Overview ¶
Package darwin implements the macOS backend (AppKit + WKWebView) in pure Go: Objective-C is driven through the runtime with purego, no cgo.
Index ¶
- func EnableNotificationSenders()
- func TestAccessibilityAttribute(handle uintptr, label, attr string) (value string, settable, named, ok bool)
- func TestAccessibilityPerform(handle uintptr, label, action, value string) bool
- func TestAppClick(handle uintptr, x, y float64)
- func TestAppKey(code uint16, chars string)
- func TestAppPress(handle uintptr, x, y float64, down bool)
- func TestClick(handle uintptr, x, y float64)
- func TestClickAndType(handle uintptr, x, y float64, text string) bool
- func TestCollectionBehavior(handle uintptr) uint
- func TestCompose(handle uintptr, text string, caret int, commit bool) bool
- func TestComposeOver(handle uintptr, text string, caret int, commit bool, from, length int) bool
- func TestControlClick(handle uintptr, x, y float64)
- func TestDockInspector(handle uintptr) bool
- func TestDockMenu(click int) []string
- func TestDockTileImage() []byte
- func TestDocumentChrome(handle uintptr) (title, file string, icon, edited bool)
- func TestDrag(handle uintptr, points [][2]float64)
- func TestDropData(handle uintptr, x, y float64, data transfer.Data, ...) (operation transfer.Operation, dropped bool)
- func TestDropFiles(handle uintptr, x, y float64, paths []string) (over, dropped bool)
- func TestEndSheet(handle uintptr) bool
- func TestEndSheetButton(handle uintptr, i int) bool
- func TestFullScreenHidesToolbar(handle uintptr) bool
- func TestInputClient(handle uintptr) (selected [2]int, document string)
- func TestInspectorPlace(handle uintptr) string
- func TestIsFrontmost() bool
- func TestKey(handle uintptr, code uint16, chars string) bool
- func TestKeyShift(handle uintptr, code uint16, chars string, shift bool) bool
- func TestObserve(handle uintptr) (stop func())
- func TestOnScreen(handle uintptr) bool
- func TestPageKeyShift(handle uintptr, code uint16, chars string, shift bool) bool
- func TestPerformKeyEquivalent(key string, shift bool) bool
- func TestPerformMenuItem(path ...string) error
- func TestRecentDocuments() []string
- func TestSetDroppedFiles(handle uintptr, paths []string)
- func TestSetWindowAppearance(handle uintptr, dark bool)
- func TestSheet(handle uintptr) (texts, buttons []string, ok bool)
- func TestSideButton(handle uintptr, back bool) bool
- func TestTabFocusesLinks(handle uintptr) bool
- func TestTrafficLights(handle uintptr) (x, y float64)
- func TestWebViewAttached(handle uintptr) bool
- type Backend
- func (b *Backend) App() platform.AppController
- func (b *Backend) Applications() ([]platform.Application, error)
- func (b *Backend) Clipboard() platform.Clipboard
- func (b *Backend) Dialogs() platform.Dialogs
- func (b *Backend) Init(h platform.AppHandler, opts platform.AppOptions) error
- func (b *Backend) IsMainThread() bool
- func (b *Backend) Name() string
- func (b *Backend) Network() platform.Network
- func (*Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)
- func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)
- func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
- func (b *Backend) NotificationsSupported() bool
- func (b *Backend) PopupMenu(m *platform.Menu, pw platform.Window, pos *platform.Point)
- func (b *Backend) Power() platform.Power
- func (b *Backend) Quit()
- func (b *Backend) RegisterHotkey(hid int, acc string) error
- func (b *Backend) RemoveAllNotifications()
- func (b *Backend) RemoveNotification(ident string)
- func (*Backend) ReplaceFile(target, replacement string) error
- func (b *Backend) Run() error
- func (b *Backend) Screen() platform.Screen
- func (b *Backend) Secrets() platform.Secrets
- func (b *Backend) SetApplicationMenu(m *platform.Menu)
- func (b *Backend) Shell() platform.Shell
- func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
- func (b *Backend) Signal()
- func (b *Backend) Step()
- func (b *Backend) Theme() platform.Theme
- func (b *Backend) UnregisterHotkey(hid int)
- func (b *Backend) UpdateMenuItem(it *platform.MenuItem)
- func (b *Backend) Wake()
- func (b *Backend) WebViewAvailable() bool
- type NSPoint
- type NSRect
- type NSSize
- type TestAccessNode
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
TestCollectionBehavior returns a window's NSWindowCollectionBehavior.
func TestCompose ¶
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 ¶
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 ¶
TestControlClick Control-clicks (x, y), in points from the top-left corner of a window's content.
func TestDockInspector ¶
TestDockInspector opens the web inspector of a window docked to it, and reports whether the window has one.
func TestDockMenu ¶
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 ¶
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 ¶
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 ¶
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 ¶
TestEndSheet ends the sheet attached to a window as if its first button was clicked, and reports whether there was one.
func TestEndSheetButton ¶
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 ¶
TestFullScreenHidesToolbar reports whether a window asks to hide its toolbar with the menu bar when it enters full screen.
func TestInputClient ¶
TestInputClient returns what a window's surface tells input methods: the selected range and the whole text of their document.
func TestInspectorPlace ¶
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 ¶
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 ¶
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 ¶
TestOnScreen reports whether some of a window shows on screen, as the window server reports once it put the window there.
func TestPageKeyShift ¶
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 ¶
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 ¶
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 ¶
TestSetDroppedFiles makes paths the files of the next drop on a window's page, as if they had been dragged there.
func TestSetWindowAppearance ¶
TestSetWindowAppearance gives a window its own dark or light appearance, apart from the application's.
func TestSheet ¶
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 ¶
TestSideButton presses and releases a mouse's back or forward button (buttons 3 and 4) in a window showing native UI.
func TestTabFocusesLinks ¶
TestTabFocusesLinks reports whether Tab reaches links and form controls that are not text fields in a window's page.
func TestTrafficLights ¶
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 ¶
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 (*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) Init ¶
func (b *Backend) Init(h platform.AppHandler, opts platform.AppOptions) error
func (*Backend) IsMainThread ¶
func (*Backend) NewFileWatch ¶
func (*Backend) NewWindow ¶
func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
func (*Backend) NotificationsSupported ¶
func (*Backend) RemoveAllNotifications ¶
func (b *Backend) RemoveAllNotifications()
func (*Backend) RemoveNotification ¶
func (*Backend) ReplaceFile ¶
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) SetApplicationMenu ¶
func (*Backend) ShowNotification ¶
func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
func (*Backend) UnregisterHotkey ¶
func (*Backend) UpdateMenuItem ¶
func (*Backend) Wake ¶
func (b *Backend) Wake()
Wake makes a pending Step return. It is called from any goroutine.
func (*Backend) WebViewAvailable ¶
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 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.
Source Files
¶
- access.go
- access_text.go
- app.go
- apps.go
- cf.go
- clipboard.go
- cookies.go
- deeplink.go
- dialog.go
- dock.go
- hotkey.go
- icon.go
- locale.go
- login.go
- menu.go
- network.go
- notify.go
- notify_communication.go
- objc.go
- popover.go
- power.go
- replace.go
- scheme.go
- secrets.go
- surface.go
- surface_drag.go
- surface_input.go
- system.go
- testhooks.go
- watch.go
- webview.go
- window.go