gioui.org@v0.6.1-0.20240506124620-7a9ce51988ce/app/doc.go (about) 1 // SPDX-License-Identifier: Unlicense OR MIT 2 3 /* 4 Package app provides a platform-independent interface to operating system 5 functionality for running graphical user interfaces. 6 7 See https://gioui.org for instructions to set up and run Gio programs. 8 9 # Windows 10 11 A Window is run by calling its Event method in a loop. The first time a 12 method on Window is called, a new GUI window is created and shown. On mobile 13 platforms or when Gio is embedded in another project, Window merely connects 14 with a previously created GUI window. 15 16 The most important event is [FrameEvent] that prompts an update of the window 17 contents. 18 19 For example: 20 21 w := new(app.Window) 22 for { 23 e := w.Event() 24 if e, ok := e.(app.FrameEvent); ok { 25 ops.Reset() 26 // Add operations to ops. 27 ... 28 // Completely replace the window contents and state. 29 e.Frame(ops) 30 } 31 } 32 33 A program must keep receiving events from the event channel until 34 [DestroyEvent] is received. 35 36 # Main 37 38 The Main function must be called from a program's main function, to hand over 39 control of the main thread to operating systems that need it. 40 41 Because Main is also blocking on some platforms, the event loop of a Window must run in a goroutine. 42 43 For example, to display a blank but otherwise functional window: 44 45 package main 46 47 import "gioui.org/app" 48 49 func main() { 50 go func() { 51 w := app.NewWindow() 52 for { 53 w.Event() 54 } 55 }() 56 app.Main() 57 } 58 59 # Permissions 60 61 The packages under gioui.org/app/permission should be imported 62 by a Gio program or by one of its dependencies to indicate that specific 63 operating-system permissions are required. Please see documentation for 64 package gioui.org/app/permission for more information. 65 */ 66 package app