fyne

package module
v0.0.0-...-baf1b81 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

README

Go API Reference Latest Release Join us on Slack
Code Status Build Status Coverage Status

About

Fyne is an easy-to-use UI toolkit and app API written in Go. It is designed to build applications that run on desktop and mobile devices with a single codebase.

Version 2.4 is the current release of the Fyne API, it added rounded corners, emoji, layout debug support and table headers, along with a large number of smaller feature additions. We are now working towards the next big release, codenamed Elgin and more news will follow in our news feeds and GitHub project.

Prerequisites

To develop apps using Fyne you will need Go version 1.17 or later, a C compiler and your system's development tools. If you're not sure if that's all installed or you don't know how then check out our Getting Started document.

Using the standard go tools you can install Fyne's core library using:

go get fyne.io/fyne/v2@latest

After importing a new module, run the following command before compiling the code for the first time. Avoid running it before writing code that uses the module to prevent accidental removal of dependencies:

go mod tidy

Widget demo

To run a showcase of the features of Fyne execute the following:

go install fyne.io/fyne/v2/cmd/fyne_demo@latest
fyne_demo

And you should see something like this (after you click a few buttons):

Fyne Demo Dark Theme

Or if you are using the light theme:

Fyne Demo Light Theme

And even running on a mobile device:

Fyne Demo Mobile Light Theme

Getting Started

Fyne is designed to be really easy to code with. If you have followed the prerequisite steps above then all you need is a Go IDE (or a text editor).

Open a new file and you're ready to write your first app!

package main

import (
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	hello := widget.NewLabel("Hello Fyne!")
	w.SetContent(container.NewVBox(
		hello,
		widget.NewButton("Hi!", func() {
			hello.SetText("Welcome :)")
		}),
	))

	w.ShowAndRun()
}

And you can run that simply as:

go run main.go

It should look like this:

Fyne Hello Dark Theme Fyne Hello Dark Theme

Run in mobile simulation

There is a helpful mobile simulation mode that gives a hint of how your app would work on a mobile device:

go run -tags mobile main.go

Another option is to use fyne command, see Packaging for mobile.

Installing

Using go install will copy the executable into your go bin dir. To install the application with icons etc into your operating system's standard application location you can use the fyne utility and the "install" subcommand.

go install fyne.io/fyne/v2/cmd/fyne@latest
fyne install

Packaging for mobile

To run on a mobile device it is necessary to package up the application. To do this we can use the fyne utility "package" subcommand. You will need to add appropriate parameters as prompted, but the basic command is shown below. Once packaged you can install using the platform development tools or the fyne "install" subcommand.

fyne package -os android -appID my.domain.appname
fyne install -os android

The built Android application can run either in a real device or an Android emulator. However, building for iOS is slightly different. If the "-os" argument is "ios", it is build only for a real iOS device. Specify "-os" to "iossimulator" allows the application be able to run in an iOS simulator:

fyne package -os ios -appID my.domain.appname
fyne package -os iossimulator -appID my.domain.appname

Preparing a release

Using the fyne utility "release" subcommand you can package up your app for release to app stores and market places. Make sure you have the standard build tools installed and have followed the platform documentation for setting up accounts and signing. Then you can execute something like the following, notice the -os ios parameter allows building an iOS app from macOS computer. Other combinations work as well :)

$ fyne release -os ios -certificate "Apple Distribution" -profile "My App Distribution" -appID "com.example.myapp"

The above command will create a '.ipa' file that can then be uploaded to the iOS App Store.

Documentation

More documentation is available at the Fyne developer website or on pkg.go.dev.

Examples

You can find many example applications in the examples repository. Alternatively a list of applications using fyne can be found at our website.

Shipping the Fyne Toolkit

All Fyne apps will work without pre-installed libraries, this is one reason the apps are so portable. However, if looking to support Fyne in a bigger way on your operating system then you can install some utilities that help to make a more complete experience.

Additional apps

It is recommended that you install the following additional apps:

app go install description
fyne_settings fyne.io/fyne/v2/cmd/fyne_settings A GUI for managing your global Fyne settings like theme and scaling
apps github.com/fyne-io/apps A graphical installer for the Fyne apps listed at https://apps.fyne.io

These are optional applications but can help to create a more complete desktop experience.

FyneDesk (Linux / BSD)

To go all the way with Fyne on your desktop / laptop computer you could install FyneDesk as well :)

FyneDesk screenshopt in dark mode

Documentation

Overview

Package fyne describes the objects and components available to any Fyne app. These can all be created, manipulated and tested without rendering (for speed). Your main package should use the app package to create an application with a default driver that will render your UI.

A simple application may look like this:

package main

import "fyne.io/fyne/v2/app"
import "fyne.io/fyne/v2/container"
import "fyne.io/fyne/v2/widget"

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	hello := widget.NewLabel("Hello Fyne!")
	w.SetContent(container.NewVBox(
		hello,
		widget.NewButton("Hi!", func() {
			hello.SetText("Welcome :)")
		}),
	))

	w.ShowAndRun()
}

Index

Constants

View Source
const AnimationRepeatForever = -1

AnimationRepeatForever is an AnimationCount value that indicates it should not stop looping.

Since: 2.0

View Source
const KeyModifierShortcutDefault = KeyModifierControl

KeyModifierShortcutDefault is the default key modifier for shortcuts (Control or Command).

Since: 2.2

Variables

View Source
var (
	// AnimationEaseInOut is the default easing, it starts slowly, accelerates to the middle and slows to the end.
	//
	// Since: 2.0
	AnimationEaseInOut = animationEaseInOut
	// AnimationEaseIn starts slowly and accelerates to the end.
	//
	// Since: 2.0
	AnimationEaseIn = animationEaseIn
	// AnimationEaseOut starts at speed and slows to the end.
	//
	// Since: 2.0
	AnimationEaseOut = animationEaseOut
	// AnimationLinear is a linear mapping for animations that progress uniformly through their duration.
	//
	// Since: 2.0
	AnimationLinear = animationLinear
)

Functions

func IsHorizontal

func IsHorizontal(orient DeviceOrientation) bool

IsHorizontal is a helper utility that determines if a passed orientation is horizontal

func IsVertical

func IsVertical(orient DeviceOrientation) bool

IsVertical is a helper utility that determines if a passed orientation is vertical

func LogError

func LogError(reason string, err error)

LogError reports an error to the command line with the specified err cause, if not nil. The function also reports basic information about the code location.

func Max

func Max(x, y float32) float32

Max returns the larger of the passed values.

func Min

func Min(x, y float32) float32

Min returns the smaller of the passed values.

func SetCurrentApp

func SetCurrentApp(current App)

SetCurrentApp is an internal function to set the app instance currently running.

Types

type Animation

type Animation struct {
	AutoReverse bool
	Curve       AnimationCurve
	Duration    time.Duration
	RepeatCount int
	Tick        func(float32)
}

Animation represents an animated element within a Fyne canvas. These animations may control individual objects or entire scenes.

Since: 2.0

func NewAnimation

func NewAnimation(d time.Duration, fn func(float32)) *Animation

NewAnimation creates a very basic animation where the callback function will be called for every rendered frame between time.Now() and the specified duration. The callback values start at 0.0 and will be 1.0 when the animation completes.

Since: 2.0

func (*Animation) Start

func (a *Animation) Start()

Start registers the animation with the application run-loop and starts its execution.

func (*Animation) Stop

func (a *Animation) Stop()

Stop will end this animation and remove it from the run-loop.

type AnimationCurve

type AnimationCurve func(float32) float32

AnimationCurve represents an animation algorithm for calculating the progress through a timeline. Custom animations can be provided by implementing the "func(float32) float32" definition. The input parameter will start at 0.0 when an animation starts and travel up to 1.0 at which point it will end. A linear animation would return the same output value as is passed in.

type App

type App interface {
	// Create a new window for the application.
	// The first window to open is considered the "master" and when closed
	// the application will exit.
	NewWindow(title string) Window

	// Open a URL in the default browser application.
	OpenURL(url *url.URL) error

	// Icon returns the application icon, this is used in various ways
	// depending on operating system.
	// This is also the default icon for new windows.
	Icon() Resource

	// SetIcon sets the icon resource used for this application instance.
	SetIcon(Resource)

	// Run the application - this starts the event loop and waits until Quit()
	// is called or the last window closes.
	// This should be called near the end of a main() function as it will block.
	Run()

	// Calling Quit on the application will cause the application to exit
	// cleanly, closing all open windows.
	// This function does no thing on a mobile device as the application lifecycle is
	// managed by the operating system.
	Quit()

	// Driver returns the driver that is rendering this application.
	// Typically not needed for day to day work, mostly internal functionality.
	Driver() Driver

	// UniqueID returns the application unique identifier, if set.
	// This must be set for use of the Preferences() functions... see NewWithId(string)
	UniqueID() string

	// SendNotification sends a system notification that will be displayed in the operating system's notification area.
	SendNotification(*Notification)

	// Settings return the globally set settings, determining theme and so on.
	Settings() Settings

	// Preferences returns the application preferences, used for storing configuration and state
	Preferences() Preferences

	// Storage returns a storage handler specific to this application.
	Storage() Storage

	// Lifecycle returns a type that allows apps to hook in to lifecycle events.
	//
	// Since: 2.1
	Lifecycle() Lifecycle

	// Metadata returns the application metadata that was set at compile time.
	//
	// Since: 2.2
	Metadata() AppMetadata

	// CloudProvider returns the current app cloud provider,
	// if one has been registered by the developer or chosen by the user.
	//
	// Since: 2.3
	CloudProvider() CloudProvider // get the (if any) configured provider

	// SetCloudProvider allows developers to specify how this application should integrate with cloud services.
	// See `fyne.io/cloud` package for implementation details.
	//
	// Since: 2.3
	SetCloudProvider(CloudProvider) // configure cloud for this app
}

An App is the definition of a graphical application. Apps can have multiple windows, by default they will exit when all windows have been closed. This can be modified using SetMaster() or SetCloseIntercept(). To start an application you need to call Run() somewhere in your main() function. Alternatively use the window.ShowAndRun() function for your main window.

func CurrentApp

func CurrentApp() App

CurrentApp returns the current application, for which there is only 1 per process.

type AppMetadata

type AppMetadata struct {
	// ID is the unique ID of this application, used by many distribution platforms.
	ID string
	// Name is the human friendly name of this app.
	Name string
	// Version represents the version of this application, normally following semantic versioning.
	Version string
	// Build is the build number of this app, some times appended to the version number.
	Build int
	// Icon contains, if present, a resource of the icon that was bundled at build time.
	Icon Resource
	// Release if true this binary was build in release mode
	// Since 2.3
	Release bool
	// Custom contain the custom metadata defined either in FyneApp.toml or on the compile command line
	// Since 2.3
	Custom map[string]string
}

AppMetadata captures the build metadata for an application.

Since: 2.2

type BuildType

type BuildType int

BuildType defines different modes that an application can be built using.

const (
	// BuildStandard is the normal build mode - it is not debug, test or release mode.
	BuildStandard BuildType = iota
	// BuildDebug is used when a developer would like more information and visual output for app debugging.
	BuildDebug
	// BuildRelease is a final production build, it is like BuildStandard but will use distribution certificates.
	// A release build is typically going to connect to live services and is not usually used during development.
	BuildRelease
)

type Canvas

type Canvas interface {
	Content() CanvasObject
	SetContent(CanvasObject)

	Refresh(CanvasObject)

	// Focus makes the provided item focused.
	// The item has to be added to the contents of the canvas before calling this.
	Focus(Focusable)
	// FocusNext focuses the next focusable item.
	// If no item is currently focused, the first focusable item is focused.
	// If the last focusable item is currently focused, the first focusable item is focused.
	//
	// Since: 2.0
	FocusNext()
	// FocusPrevious focuses the previous focusable item.
	// If no item is currently focused, the last focusable item is focused.
	// If the first focusable item is currently focused, the last focusable item is focused.
	//
	// Since: 2.0
	FocusPrevious()
	Unfocus()
	Focused() Focusable

	// Size returns the current size of this canvas
	Size() Size
	// Scale returns the current scale (multiplication factor) this canvas uses to render
	// The pixel size of a CanvasObject can be found by multiplying by this value.
	Scale() float32

	// Overlays returns the overlay stack.
	Overlays() OverlayStack

	OnTypedRune() func(rune)
	SetOnTypedRune(func(rune))
	OnTypedKey() func(*KeyEvent)
	SetOnTypedKey(func(*KeyEvent))
	AddShortcut(shortcut Shortcut, handler func(shortcut Shortcut))
	RemoveShortcut(shortcut Shortcut)

	Capture() image.Image

	// PixelCoordinateForPosition returns the x and y pixel coordinate for a given position on this canvas.
	// This can be used to find absolute pixel positions or pixel offsets relative to an object top left.
	PixelCoordinateForPosition(Position) (int, int)

	// InteractiveArea returns the position and size of the central interactive area.
	// Operating system elements may overlap the portions outside this area and widgets should avoid being outside.
	//
	// Since: 1.4
	InteractiveArea() (Position, Size)
}

Canvas defines a graphical canvas to which a CanvasObject or Container can be added. Each canvas has a scale which is automatically applied during the render process.

type CanvasObject

type CanvasObject interface {

	// MinSize returns the minimum size this object needs to be drawn.
	MinSize() Size
	// Move moves this object to the given position relative to its parent.
	// This should only be called if your object is not in a container with a layout manager.
	Move(Position)
	// Position returns the current position of the object relative to its parent.
	Position() Position
	// Resize resizes this object to the given size.
	// This should only be called if your object is not in a container with a layout manager.
	Resize(Size)
	// Size returns the current size of this object.
	Size() Size

	// Hide hides this object.
	Hide()
	// Visible returns whether this object is visible or not.
	Visible() bool
	// Show shows this object.
	Show()

	// Refresh must be called if this object should be redrawn because its inner state changed.
	Refresh()
}

CanvasObject describes any graphical object that can be added to a canvas. Objects have a size and position that can be controlled through this API. MinSize is used to determine the minimum size which this object should be displayed. An object will be visible by default but can be hidden with Hide() and re-shown with Show().

Note: If this object is controlled as part of a Layout you should not call Resize(Size) or Move(Position).

type Clipboard

type Clipboard interface {
	// Content returns the clipboard content
	Content() string
	// SetContent sets the clipboard content
	SetContent(content string)
}

Clipboard represents the system clipboard interface

type CloudProvider

type CloudProvider interface {
	// ProviderDescription returns a more detailed description of this cloud provider.
	ProviderDescription() string
	// ProviderIcon returns an icon resource that is associated with the given cloud service.
	ProviderIcon() Resource
	// ProviderName returns the name of this cloud provider, usually the name of the service it uses.
	ProviderName() string

	// Cleanup is called when this provider is no longer used and should be disposed.
	// This is guaranteed to execute before a new provider is `Setup`
	Cleanup(App)
	// Setup is called when this provider is being used for the first time.
	// Returning an error will exit the cloud setup process, though it can be retried.
	Setup(App) error
}

CloudProvider specifies the identifying information of a cloud provider. This information is mostly used by the `fyne.io/cloud ShowSettings' user flow.

Since: 2.3

type CloudProviderPreferences

type CloudProviderPreferences interface {
	// CloudPreferences returns a preference provider that will sync values to the cloud this provider uses.
	CloudPreferences(App) Preferences
}

CloudProviderPreferences interface defines the functionality that a cloud provider will include if it is capable of synchronizing user preferences.

Since: 2.3

type CloudProviderStorage

type CloudProviderStorage interface {
	// CloudStorage returns a storage provider that will sync documents to the cloud this provider uses.
	CloudStorage(App) Storage
}

CloudProviderStorage interface defines the functionality that a cloud provider will include if it is capable of synchronizing user documents.

Since: 2.3

type Container

type Container struct {
	Hidden bool // Is this Container hidden

	Layout Layout // The Layout algorithm for arranging child CanvasObjects

	Objects []CanvasObject // The set of CanvasObjects this container holds
	// contains filtered or unexported fields
}

Container is a CanvasObject that contains a collection of child objects. The layout of the children is set by the specified Layout.

func NewContainer deprecated

func NewContainer(objects ...CanvasObject) *Container

NewContainer returns a new Container instance holding the specified CanvasObjects.

Deprecated: Use container.NewWithoutLayout() to create a container that uses manual layout.

func NewContainerWithLayout deprecated

func NewContainerWithLayout(layout Layout, objects ...CanvasObject) *Container

NewContainerWithLayout returns a new Container instance holding the specified CanvasObjects which will be laid out according to the specified Layout.

Deprecated: Use container.New() instead

func NewContainerWithoutLayout deprecated

func NewContainerWithoutLayout(objects ...CanvasObject) *Container

NewContainerWithoutLayout returns a new Container instance holding the specified CanvasObjects that are manually arranged.

Deprecated: Use container.NewWithoutLayout() instead

func (*Container) Add

func (c *Container) Add(add CanvasObject)

Add appends the specified object to the items this container manages.

Since: 1.4

func (*Container) AddObject deprecated

func (c *Container) AddObject(o CanvasObject)

AddObject adds another CanvasObject to the set this Container holds.

Deprecated: Use replacement Add() function

func (*Container) Hide

func (c *Container) Hide()

Hide sets this container, and all its children, to be not visible.

func (*Container) MinSize

func (c *Container) MinSize() Size

MinSize calculates the minimum size of a Container. This is delegated to the Layout, if specified, otherwise it will mimic MaxLayout.

func (*Container) Move

func (c *Container) Move(pos Position)

Move the container (and all its children) to a new position, relative to its parent.

func (*Container) Position

func (c *Container) Position() Position

Position gets the current position of this Container, relative to its parent.

func (*Container) Refresh

func (c *Container) Refresh()

Refresh causes this object to be redrawn in it's current state

func (*Container) Remove

func (c *Container) Remove(rem CanvasObject)

Remove updates the contents of this container to no longer include the specified object. This method is not intended to be used inside a loop, to remove all the elements. It is much more efficient to call RemoveAll() instead.

func (*Container) RemoveAll

func (c *Container) RemoveAll()

RemoveAll updates the contents of this container to no longer include any objects.

Since: 2.2

func (*Container) Resize

func (c *Container) Resize(size Size)

Resize sets a new size for the Container.

func (*Container) Show

func (c *Container) Show()

Show sets this container, and all its children, to be visible.

func (*Container) Size

func (c *Container) Size() Size

Size returns the current size of this container.

func (*Container) Visible

func (c *Container) Visible() bool

Visible returns true if the container is currently visible, false otherwise.

type Delta

type Delta struct {
	DX, DY float32
}

Delta is a generic X, Y coordinate, size or movement representation.

func NewDelta

func NewDelta(dx float32, dy float32) Delta

NewDelta returns a newly allocated Delta representing a movement in the X and Y axis.

func (Delta) Components

func (v Delta) Components() (float32, float32)

Components returns the X and Y elements of this Delta.

func (Delta) IsZero

func (v Delta) IsZero() bool

IsZero returns whether the Position is at the zero-point.

type Device

type Device interface {
	Orientation() DeviceOrientation
	IsMobile() bool
	IsBrowser() bool
	HasKeyboard() bool
	SystemScaleForWindow(Window) float32
}

Device provides information about the devices the code is running on

func CurrentDevice

func CurrentDevice() Device

CurrentDevice returns the device information for the current hardware (via the driver)

type DeviceOrientation

type DeviceOrientation int

DeviceOrientation represents the different ways that a mobile device can be held

const (
	// OrientationVertical is the default vertical orientation
	OrientationVertical DeviceOrientation = iota
	// OrientationVerticalUpsideDown is the portrait orientation held upside down
	OrientationVerticalUpsideDown
	// OrientationHorizontalLeft is used to indicate a landscape orientation with the top to the left
	OrientationHorizontalLeft
	// OrientationHorizontalRight is used to indicate a landscape orientation with the top to the right
	OrientationHorizontalRight
)

type Disableable

type Disableable interface {
	Enable()
	Disable()
	Disabled() bool
}

Disableable describes any CanvasObject that can be disabled. This is primarily used with objects that also implement the Tappable interface.

type DoubleTappable

type DoubleTappable interface {
	DoubleTapped(*PointEvent)
}

DoubleTappable describes any CanvasObject that can also be double tapped.

type DragEvent

type DragEvent struct {
	PointEvent
	Dragged Delta
}

DragEvent defines the parameters of a pointer or other drag event. The DraggedX and DraggedY fields show how far the item was dragged since the last event.

type Draggable

type Draggable interface {
	Dragged(*DragEvent)
	DragEnd()
}

Draggable indicates that a CanvasObject can be dragged. This is used for any item that the user has indicated should be moved across the screen.

type Driver

type Driver interface {
	// CreateWindow creates a new UI Window.
	CreateWindow(string) Window
	// AllWindows returns a slice containing all app windows.
	AllWindows() []Window

	// RenderedTextSize returns the size required to render the given string of specified
	// font size and style. It also returns the height to text baseline, measured from the top.
	RenderedTextSize(text string, fontSize float32, style TextStyle) (size Size, baseline float32)

	// CanvasForObject returns the canvas that is associated with a given CanvasObject.
	CanvasForObject(CanvasObject) Canvas
	// AbsolutePositionForObject returns the position of a given CanvasObject relative to the top/left of a canvas.
	AbsolutePositionForObject(CanvasObject) Position

	// Device returns the device that the application is currently running on.
	Device() Device
	// Run starts the main event loop of the driver.
	Run()
	// Quit closes the driver and open windows, then exit the application.
	// On some some operating systems this does nothing, for example iOS and Android.
	Quit()

	// StartAnimation registers a new animation with this driver and requests it be started.
	StartAnimation(*Animation)
	// StopAnimation stops an animation and unregisters from this driver.
	StopAnimation(*Animation)
}

Driver defines an abstract concept of a Fyne render driver. Any implementation must provide at least these methods.

type Focusable

type Focusable interface {
	// FocusGained is a hook called by the focus handling logic after this object gained the focus.
	FocusGained()
	// FocusLost is a hook called by the focus handling logic after this object lost the focus.
	FocusLost()

	// TypedRune is a hook called by the input handling logic on text input events if this object is focused.
	TypedRune(rune)
	// TypedKey is a hook called by the input handling logic on key events if this object is focused.
	TypedKey(*KeyEvent)
}

Focusable describes any CanvasObject that can respond to being focused. It will receive the FocusGained and FocusLost events appropriately. When focused it will also have TypedRune called as text is input and TypedKey called when other keys are pressed.

Note: You must not change canvas state (including overlays or focus) in FocusGained or FocusLost or you would end up with a dead-lock.

type HardwareKey

type HardwareKey struct {
	// ScanCode represents a hardware ID for (normally desktop) keyboard events.
	ScanCode int
}

HardwareKey contains information associated with physical key events Most applications should use KeyName for cross-platform compatibility.

type KeyEvent

type KeyEvent struct {
	// Name describes the keyboard event that is consistent across platforms.
	Name KeyName
	// Physical is a platform specific field that reports the hardware information of physical keyboard events.
	Physical HardwareKey
}

KeyEvent describes a keyboard input event.

type KeyModifier

type KeyModifier int

KeyModifier represents any modifier key (shift etc.) that is being pressed together with a key.

Since: 2.2

const (
	// KeyModifierShift represents a shift key being held
	//
	// Since: 2.2
	KeyModifierShift KeyModifier = 1 << iota
	// KeyModifierControl represents the ctrl key being held
	//
	// Since: 2.2
	KeyModifierControl
	// KeyModifierAlt represents either alt keys being held
	//
	// Since: 2.2
	KeyModifierAlt
	// KeyModifierSuper represents either super keys being held
	//
	// Since: 2.2
	KeyModifierSuper
)

type KeyName

type KeyName string

KeyName represents the name of a key that has been pressed.

const (
	// KeyEscape is the "esc" key
	KeyEscape KeyName = "Escape"
	// KeyReturn is the carriage return (main keyboard)
	KeyReturn KeyName = "Return"
	// KeyTab is the tab advance key
	KeyTab KeyName = "Tab"
	// KeyBackspace is the delete-before-cursor key
	KeyBackspace KeyName = "BackSpace"
	// KeyInsert is the insert mode key
	KeyInsert KeyName = "Insert"
	// KeyDelete is the delete-after-cursor key
	KeyDelete KeyName = "Delete"
	// KeyRight is the right arrow key
	KeyRight KeyName = "Right"
	// KeyLeft is the left arrow key
	KeyLeft KeyName = "Left"
	// KeyDown is the down arrow key
	KeyDown KeyName = "Down"
	// KeyUp is the up arrow key
	KeyUp KeyName = "Up"
	// KeyPageUp is the page up num-pad key
	KeyPageUp KeyName = "Prior"
	// KeyPageDown is the page down num-pad key
	KeyPageDown KeyName = "Next"
	// KeyHome is the line-home key
	KeyHome KeyName = "Home"
	// KeyEnd is the line-end key
	KeyEnd KeyName = "End"

	// KeyF1 is the first function key
	KeyF1 KeyName = "F1"
	// KeyF2 is the second function key
	KeyF2 KeyName = "F2"
	// KeyF3 is the third function key
	KeyF3 KeyName = "F3"
	// KeyF4 is the fourth function key
	KeyF4 KeyName = "F4"
	// KeyF5 is the fifth function key
	KeyF5 KeyName = "F5"
	// KeyF6 is the sixth function key
	KeyF6 KeyName = "F6"
	// KeyF7 is the seventh function key
	KeyF7 KeyName = "F7"
	// KeyF8 is the eighth function key
	KeyF8 KeyName = "F8"
	// KeyF9 is the ninth function key
	KeyF9 KeyName = "F9"
	// KeyF10 is the tenth function key
	KeyF10 KeyName = "F10"
	// KeyF11 is the eleventh function key
	KeyF11 KeyName = "F11"
	// KeyF12 is the twelfth function key
	KeyF12 KeyName = "F12"

	// KeyEnter is the enter/ return key (keypad)
	KeyEnter KeyName = "KP_Enter"

	// Key0 represents the key 0
	Key0 KeyName = "0"
	// Key1 represents the key 1
	Key1 KeyName = "1"
	// Key2 represents the key 2
	Key2 KeyName = "2"
	// Key3 represents the key 3
	Key3 KeyName = "3"
	// Key4 represents the key 4
	Key4 KeyName = "4"
	// Key5 represents the key 5
	Key5 KeyName = "5"
	// Key6 represents the key 6
	Key6 KeyName = "6"
	// Key7 represents the key 7
	Key7 KeyName = "7"
	// Key8 represents the key 8
	Key8 KeyName = "8"
	// Key9 represents the key 9
	Key9 KeyName = "9"
	// KeyA represents the key A
	KeyA KeyName = "A"
	// KeyB represents the key B
	KeyB KeyName = "B"
	// KeyC represents the key C
	KeyC KeyName = "C"
	// KeyD represents the key D
	KeyD KeyName = "D"
	// KeyE represents the key E
	KeyE KeyName = "E"
	// KeyF represents the key F
	KeyF KeyName = "F"
	// KeyG represents the key G
	KeyG KeyName = "G"
	// KeyH represents the key H
	KeyH KeyName = "H"
	// KeyI represents the key I
	KeyI KeyName = "I"
	// KeyJ represents the key J
	KeyJ KeyName = "J"
	// KeyK represents the key K
	KeyK KeyName = "K"
	// KeyL represents the key L
	KeyL KeyName = "L"
	// KeyM represents the key M
	KeyM KeyName = "M"
	// KeyN represents the key N
	KeyN KeyName = "N"
	// KeyO represents the key O
	KeyO KeyName = "O"
	// KeyP represents the key P
	KeyP KeyName = "P"
	// KeyQ represents the key Q
	KeyQ KeyName = "Q"
	// KeyR represents the key R
	KeyR KeyName = "R"
	// KeyS represents the key S
	KeyS KeyName = "S"
	// KeyT represents the key T
	KeyT KeyName = "T"
	// KeyU represents the key U
	KeyU KeyName = "U"
	// KeyV represents the key V
	KeyV KeyName = "V"
	// KeyW represents the key W
	KeyW KeyName = "W"
	// KeyX represents the key X
	KeyX KeyName = "X"
	// KeyY represents the key Y
	KeyY KeyName = "Y"
	// KeyZ represents the key Z
	KeyZ KeyName = "Z"

	// KeySpace is the space key
	KeySpace KeyName = "Space"
	// KeyApostrophe is the key "'"
	KeyApostrophe KeyName = "'"
	// KeyComma is the key ","
	KeyComma KeyName = ","
	// KeyMinus is the key "-"
	KeyMinus KeyName = "-"
	// KeyPeriod is the key "." (full stop)
	KeyPeriod KeyName = "."
	// KeySlash is the key "/"
	KeySlash KeyName = "/"
	// KeyBackslash is the key "\"
	KeyBackslash KeyName = "\\"
	// KeyLeftBracket is the key "["
	KeyLeftBracket KeyName = "["
	// KeyRightBracket is the key "]"
	KeyRightBracket KeyName = "]"
	// KeySemicolon is the key ";"
	KeySemicolon KeyName = ";"
	// KeyEqual is the key "="
	KeyEqual KeyName = "="
	// KeyAsterisk is the keypad key "*"
	KeyAsterisk KeyName = "*"
	// KeyPlus is the keypad key "+"
	KeyPlus KeyName = "+"
	// KeyBackTick is the key "`" on a US keyboard
	KeyBackTick KeyName = "`"

	// KeyUnknown is used for key events where the underlying hardware generated an
	// event that Fyne could not decode.
	//
	// Since: 2.1
	KeyUnknown KeyName = ""
)

type KeyboardShortcut

type KeyboardShortcut interface {
	Shortcut
	Key() KeyName
	Mod() KeyModifier
}

KeyboardShortcut describes a shortcut meant to be triggered by a keyboard action.

type Layout

type Layout interface {
	// Layout will manipulate the listed CanvasObjects Size and Position
	// to fit within the specified size.
	Layout([]CanvasObject, Size)
	// MinSize calculates the smallest size that will fit the listed
	// CanvasObjects using this Layout algorithm.
	MinSize(objects []CanvasObject) Size
}

Layout defines how CanvasObjects may be laid out in a specified Size.

type LegacyTheme

type LegacyTheme interface {
	BackgroundColor() color.Color
	ButtonColor() color.Color
	DisabledButtonColor() color.Color
	TextColor() color.Color
	DisabledTextColor() color.Color
	PlaceHolderColor() color.Color
	PrimaryColor() color.Color
	HoverColor() color.Color
	FocusColor() color.Color
	ScrollBarColor() color.Color
	ShadowColor() color.Color

	TextSize() int
	TextFont() Resource
	TextBoldFont() Resource
	TextItalicFont() Resource
	TextBoldItalicFont() Resource
	TextMonospaceFont() Resource

	Padding() int
	IconInlineSize() int
	ScrollBarSize() int
	ScrollBarSmallSize() int
}

LegacyTheme defines the requirements of any Fyne theme. This was previously called Theme and is kept for simpler transition of applications built before v2.0.0.

Since: 2.0

type Lifecycle

type Lifecycle interface {
	// SetOnEnteredForeground hooks into the app becoming foreground and gaining focus.
	SetOnEnteredForeground(func())
	// SetOnExitedForeground hooks into the app losing input focus and going into the background.
	SetOnExitedForeground(func())
	// SetOnStarted hooks into an event that says the app is now running.
	SetOnStarted(func())
	// SetOnStopped hooks into an event that says the app is no longer running.
	SetOnStopped(func())
}

Lifecycle represents the various phases that an app can transition through.

Since: 2.1

type ListableURI

type ListableURI interface {
	URI

	// List returns a list of child URIs of this URI.
	List() ([]URI, error)
}

ListableURI represents a URI that can have child items, most commonly a directory on disk in the native filesystem.

Since: 1.4

type MainMenu struct {
	Items []*Menu
}

MainMenu defines the data required to show a menu bar (desktop) or other appropriate top level menu.

func NewMainMenu

func NewMainMenu(items ...*Menu) *MainMenu

NewMainMenu creates a top level menu structure used by fyne.Window for displaying a menubar (or appropriate equivalent).

func (m *MainMenu) Refresh()

Refresh will instruct any rendered menus using this struct to update their display.

Since: 2.2

type Menu struct {
	Label string
	Items []*MenuItem
}

Menu stores the information required for a standard menu. A menu can pop down from a MainMenu or could be a pop out menu.

func NewMenu

func NewMenu(label string, items ...*MenuItem) *Menu

NewMenu creates a new menu given the specified label (to show in a MainMenu) and list of items to display.

func (m *Menu) Refresh()

Refresh will instruct this menu to update its display.

Since: 2.2

type MenuItem struct {
	ChildMenu *Menu
	// Since: 2.1
	IsQuit      bool
	IsSeparator bool
	Label       string
	Action      func()
	// Since: 2.1
	Disabled bool
	// Since: 2.1
	Checked bool
	// Since: 2.2
	Icon Resource
	// Since: 2.2
	Shortcut Shortcut
}

MenuItem is a single item within any menu, it contains a display Label and Action function that is called when tapped.

func NewMenuItem

func NewMenuItem(label string, action func()) *MenuItem

NewMenuItem creates a new menu item from the passed label and action parameters.

func NewMenuItemSeparator

func NewMenuItemSeparator() *MenuItem

NewMenuItemSeparator creates a menu item that is to be used as a separator.

type Notification

type Notification struct {
	Title, Content string
}

Notification represents a user notification that can be sent to the operating system.

func NewNotification

func NewNotification(title, content string) *Notification

NewNotification creates a notification that can be passed to App.SendNotification.

type OverlayStack

type OverlayStack interface {
	// Add adds an overlay on the top of the overlay stack.
	Add(overlay CanvasObject)
	// List returns the overlays currently on the overlay stack.
	List() []CanvasObject
	// Remove removes the given object and all objects above it from the overlay stack.
	Remove(overlay CanvasObject)
	// Top returns the top-most object of the overlay stack.
	Top() CanvasObject
}

OverlayStack is a stack of CanvasObjects intended to be used as overlays of a Canvas.

type PointEvent

type PointEvent struct {
	AbsolutePosition Position // The absolute position of the event
	Position         Position // The relative position of the event
}

PointEvent describes a pointer input event. The position is relative to the top-left of the CanvasObject this is triggered on.

type Position

type Position struct {
	X float32 // The position from the parent's left edge
	Y float32 // The position from the parent's top edge
}

Position describes a generic X, Y coordinate relative to a parent Canvas or CanvasObject.

func NewPos

func NewPos(x float32, y float32) Position

NewPos returns a newly allocated Position representing the specified coordinates.

func NewSquareOffsetPos

func NewSquareOffsetPos(length float32) Position

NewSquareOffsetPos returns a newly allocated Position with the same x and y position.

Since: 2.4

func (Position) Add

func (p Position) Add(v Vector2) Position

Add returns a new Position that is the result of offsetting the current position by p2 X and Y.

func (Position) AddXY

func (p Position) AddXY(x, y float32) Position

AddXY returns a new Position by adding x and y to the current one.

func (Position) Components

func (p Position) Components() (float32, float32)

Components returns the X and Y elements of this Position

func (Position) IsZero

func (p Position) IsZero() bool

IsZero returns whether the Position is at the zero-point.

func (Position) Subtract

func (p Position) Subtract(v Vector2) Position

Subtract returns a new Position that is the result of offsetting the current position by p2 -X and -Y.

func (Position) SubtractXY

func (p Position) SubtractXY(x, y float32) Position

SubtractXY returns a new Position by subtracting x and y from the current one.

type Preferences

type Preferences interface {
	// Bool looks up a bool value for the key
	Bool(key string) bool
	// BoolWithFallback looks up a bool value and returns the given fallback if not found
	BoolWithFallback(key string, fallback bool) bool
	// SetBool saves a bool value for the given key
	SetBool(key string, value bool)

	// BoolList looks up a list of bool values for the key
	//
	// Since: 2.4
	BoolList(key string) []bool
	// BoolListWithFallback looks up a list of bool values and returns the given fallback if not found
	//
	// Since: 2.4
	BoolListWithFallback(key string, fallback []bool) []bool
	// SetBoolList saves a list of bool values for the given key
	//
	// Since: 2.4
	SetBoolList(key string, value []bool)

	// Float looks up a float64 value for the key
	Float(key string) float64
	// FloatWithFallback looks up a float64 value and returns the given fallback if not found
	FloatWithFallback(key string, fallback float64) float64
	// SetFloat saves a float64 value for the given key
	SetFloat(key string, value float64)

	// FloatList looks up a list of float64 values for the key
	//
	// Since: 2.4
	FloatList(key string) []float64
	// FloatListWithFallback looks up a list of float64 values and returns the given fallback if not found
	//
	// Since: 2.4
	FloatListWithFallback(key string, fallback []float64) []float64
	// SetFloatList saves a list of float64 values for the given key
	//
	// Since: 2.4
	SetFloatList(key string, value []float64)

	// Int looks up an integer value for the key
	Int(key string) int
	// IntWithFallback looks up an integer value and returns the given fallback if not found
	IntWithFallback(key string, fallback int) int
	// SetInt saves an integer value for the given key
	SetInt(key string, value int)

	// IntList looks up a list of int values for the key
	//
	// Since: 2.4
	IntList(key string) []int
	// IntListWithFallback looks up a list of int values and returns the given fallback if not found
	//
	// Since: 2.4
	IntListWithFallback(key string, fallback []int) []int
	// SetIntList saves a list of string values for the given key
	//
	// Since: 2.4
	SetIntList(key string, value []int)

	// String looks up a string value for the key
	String(key string) string
	// StringWithFallback looks up a string value and returns the given fallback if not found
	StringWithFallback(key, fallback string) string
	// SetString saves a string value for the given key
	SetString(key string, value string)

	// StringList looks up a list of string values for the key
	//
	// Since: 2.4
	StringList(key string) []string
	// StringListWithFallback looks up a list of string values and returns the given fallback if not found
	//
	// Since: 2.4
	StringListWithFallback(key string, fallback []string) []string
	// SetStringList saves a list of string values for the given key
	//
	// Since: 2.4
	SetStringList(key string, value []string)

	// RemoveValue removes a value for the given key (not currently supported on iOS)
	RemoveValue(key string)

	// AddChangeListener allows code to be notified when some preferences change. This will fire on any update.
	AddChangeListener(func())

	// ChangeListeners returns a list of the known change listeners for this preference set.
	//
	// Since: 2.3
	ChangeListeners() []func()
}

Preferences describes the ways that an app can save and load user preferences

type Resource

type Resource interface {
	Name() string
	Content() []byte
}

Resource represents a single binary resource, such as an image or font. A resource has an identifying name and byte array content. The serialised path of a resource can be obtained which may result in a blocking filesystem write operation.

func LoadResourceFromPath

func LoadResourceFromPath(path string) (Resource, error)

LoadResourceFromPath creates a new StaticResource in memory using the contents of the specified file.

func LoadResourceFromURLString

func LoadResourceFromURLString(urlStr string) (Resource, error)

LoadResourceFromURLString creates a new StaticResource in memory using the body of the specified URL.

type ScrollEvent

type ScrollEvent struct {
	PointEvent
	Scrolled Delta
}

ScrollEvent defines the parameters of a pointer or other scroll event. The DeltaX and DeltaY represent how large the scroll was in two dimensions.

type Scrollable

type Scrollable interface {
	Scrolled(*ScrollEvent)
}

Scrollable describes any CanvasObject that can also be scrolled. This is mostly used to implement the widget.ScrollContainer.

type SecondaryTappable

type SecondaryTappable interface {
	TappedSecondary(*PointEvent)
}

SecondaryTappable describes a CanvasObject that can be right-clicked or long-tapped.

type Settings

type Settings interface {
	Theme() Theme
	SetTheme(Theme)
	// ThemeVariant defines which preferred version of a theme should be used (i.e. light or dark)
	//
	// Since: 2.0
	ThemeVariant() ThemeVariant
	Scale() float32
	// PrimaryColor indicates a user preference for a named primary color
	//
	// Since: 1.4
	PrimaryColor() string

	AddChangeListener(chan Settings)
	BuildType() BuildType

	ShowAnimations() bool
}

Settings describes the application configuration available.

type Shortcut

type Shortcut interface {
	ShortcutName() string
}

Shortcut is the interface used to describe a shortcut action

type ShortcutCopy

type ShortcutCopy struct {
	Clipboard Clipboard
}

ShortcutCopy describes a shortcut copy action.

func (*ShortcutCopy) Key

func (se *ShortcutCopy) Key() KeyName

Key returns the KeyName for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutCopy) Mod

func (se *ShortcutCopy) Mod() KeyModifier

Mod returns the KeyModifier for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutCopy) ShortcutName

func (se *ShortcutCopy) ShortcutName() string

ShortcutName returns the shortcut name

type ShortcutCut

type ShortcutCut struct {
	Clipboard Clipboard
}

ShortcutCut describes a shortcut cut action.

func (*ShortcutCut) Key

func (se *ShortcutCut) Key() KeyName

Key returns the KeyName for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutCut) Mod

func (se *ShortcutCut) Mod() KeyModifier

Mod returns the KeyModifier for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutCut) ShortcutName

func (se *ShortcutCut) ShortcutName() string

ShortcutName returns the shortcut name

type ShortcutHandler

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

ShortcutHandler is a default implementation of the shortcut handler for the canvasObject

func (*ShortcutHandler) AddShortcut

func (sh *ShortcutHandler) AddShortcut(shortcut Shortcut, handler func(shortcut Shortcut))

AddShortcut register a handler to be executed when the shortcut action is triggered

func (*ShortcutHandler) RemoveShortcut

func (sh *ShortcutHandler) RemoveShortcut(shortcut Shortcut)

RemoveShortcut removes a registered shortcut

func (*ShortcutHandler) TypedShortcut

func (sh *ShortcutHandler) TypedShortcut(shortcut Shortcut)

TypedShortcut handle the registered shortcut

type ShortcutPaste

type ShortcutPaste struct {
	Clipboard Clipboard
}

ShortcutPaste describes a shortcut paste action.

func (*ShortcutPaste) Key

func (se *ShortcutPaste) Key() KeyName

Key returns the KeyName for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutPaste) Mod

func (se *ShortcutPaste) Mod() KeyModifier

Mod returns the KeyModifier for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutPaste) ShortcutName

func (se *ShortcutPaste) ShortcutName() string

ShortcutName returns the shortcut name

type ShortcutSelectAll

type ShortcutSelectAll struct{}

ShortcutSelectAll describes a shortcut selectAll action.

func (*ShortcutSelectAll) Key

func (se *ShortcutSelectAll) Key() KeyName

Key returns the KeyName for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutSelectAll) Mod

func (se *ShortcutSelectAll) Mod() KeyModifier

Mod returns the KeyModifier for this shortcut.

Implements: KeyboardShortcut

func (*ShortcutSelectAll) ShortcutName

func (se *ShortcutSelectAll) ShortcutName() string

ShortcutName returns the shortcut name

type Shortcutable

type Shortcutable interface {
	TypedShortcut(Shortcut)
}

Shortcutable describes any CanvasObject that can respond to shortcut commands (quit, cut, copy, and paste).

type Size

type Size struct {
	Width  float32 // The number of units along the X axis.
	Height float32 // The number of units along the Y axis.
}

Size describes something with width and height.

func MeasureText

func MeasureText(text string, size float32, style TextStyle) Size

MeasureText uses the current driver to calculate the size of text when rendered.

func NewSize

func NewSize(w float32, h float32) Size

NewSize returns a newly allocated Size of the specified dimensions.

func NewSquareSize

func NewSquareSize(side float32) Size

NewSquareSize returns a newly allocated Size with the same width and height.

Since: 2.4

func (Size) Add

func (s Size) Add(v Vector2) Size

Add returns a new Size that is the result of increasing the current size by s2 Width and Height.

func (Size) AddWidthHeight

func (s Size) AddWidthHeight(width, height float32) Size

AddWidthHeight returns a new Size by adding width and height to the current one.

func (Size) Components

func (s Size) Components() (float32, float32)

Components returns the Width and Height elements of this Size

func (Size) IsZero

func (s Size) IsZero() bool

IsZero returns whether the Size has zero width and zero height.

func (Size) Max

func (s Size) Max(v Vector2) Size

Max returns a new Size that is the maximum of the current Size and s2.

func (Size) Min

func (s Size) Min(v Vector2) Size

Min returns a new Size that is the minimum of the current Size and s2.

func (Size) Subtract

func (s Size) Subtract(v Vector2) Size

Subtract returns a new Size that is the result of decreasing the current size by s2 Width and Height.

func (Size) SubtractWidthHeight

func (s Size) SubtractWidthHeight(width, height float32) Size

SubtractWidthHeight returns a new Size by subtracting width and height from the current one.

type StaticResource

type StaticResource struct {
	StaticName    string
	StaticContent []byte
}

StaticResource is a bundled resource compiled into the application. These resources are normally generated by the fyne_bundle command included in the Fyne toolkit.

func NewStaticResource

func NewStaticResource(name string, content []byte) *StaticResource

NewStaticResource returns a new static resource object with the specified name and content. Creating a new static resource in memory results in sharable binary data that may be serialised to the system cache location.

func (*StaticResource) Content

func (r *StaticResource) Content() []byte

Content returns the bytes of the bundled resource, no compression is applied but any compression on the resource is retained.

func (*StaticResource) GoString

func (r *StaticResource) GoString() string

GoString converts a Resource object to Go code. This is useful if serialising to a Go file for compilation into a binary.

func (*StaticResource) Name

func (r *StaticResource) Name() string

Name returns the unique name of this resource, usually matching the file it was generated from.

type Storage

type Storage interface {
	RootURI() URI

	Create(name string) (URIWriteCloser, error)
	Open(name string) (URIReadCloser, error)
	Save(name string) (URIWriteCloser, error)
	Remove(name string) error

	List() []string
}

Storage is used to manage file storage inside an application sandbox. The files managed by this interface are unique to the current application.

type StringValidator

type StringValidator func(string) error

StringValidator is a function signature for validating string inputs.

Since: 1.4

type Tabbable

type Tabbable interface {
	// AcceptsTab() is a hook called by the key press handling logic.
	// If it returns true then the Tab key events will be sent using TypedKey.
	AcceptsTab() bool
}

Tabbable describes any object that needs to accept the Tab key presses.

Since: 2.1

type Tappable

type Tappable interface {
	Tapped(*PointEvent)
}

Tappable describes any CanvasObject that can also be tapped. This should be implemented by buttons etc that wish to handle pointer interactions.

type TextAlign

type TextAlign int

TextAlign represents the horizontal alignment of text within a widget or canvas object.

const (
	// TextAlignLeading specifies a left alignment for left-to-right languages.
	TextAlignLeading TextAlign = iota
	// TextAlignCenter places the text centrally within the available space.
	TextAlignCenter
	// TextAlignTrailing will align the text right for a left-to-right language.
	TextAlignTrailing
)

type TextStyle

type TextStyle struct {
	Bold      bool // Should text be bold
	Italic    bool // Should text be italic
	Monospace bool // Use the system monospace font instead of regular
	// Since: 2.2
	Symbol bool // Use the system symbol font.
	// Since: 2.1
	TabWidth int // Width of tabs in spaces
}

TextStyle represents the styles that can be applied to a text canvas object or text based widget.

type TextTruncation

type TextTruncation int

TextTruncation controls how a `Label` or `Entry` will truncate its text. The default value is `TextTruncateOff` which will not truncate.

Since: 2.4

const (
	// TextTruncateOff means no truncation will be applied, it is the default.
	// This means that the minimum size of a text block will be the space required to display it fully.
	TextTruncateOff TextTruncation = iota
	// TextTruncateClip will truncate text when it reaches the end of the available space.
	TextTruncateClip
	// TextTruncateEllipsis is like regular truncation except that an ellipses (…) will be inserted
	// wherever text has been shortened to fit.
	//
	// Since: 2.4
	TextTruncateEllipsis
)

type TextWrap

type TextWrap int

TextWrap represents how text longer than the widget's width will be wrapped.

const (
	// TextWrapOff extends the widget's width to fit the text, no wrapping is applied.
	TextWrapOff TextWrap = iota
	// TextTruncate trims the text to the widget's width, no wrapping is applied.
	// If an entry is asked to truncate it will provide scrolling capabilities.
	//
	// Deprecated: Use `TextTruncateClip` value of the widget `Truncation` field instead
	TextTruncate
	// TextWrapBreak trims the line of characters to the widget's width adding the excess as new line.
	// An Entry with text wrapping will scroll vertically if there is not enough space for all the text.
	TextWrapBreak
	// TextWrapWord trims the line of words to the widget's width adding the excess as new line.
	// An Entry with text wrapping will scroll vertically if there is not enough space for all the text.
	TextWrapWord
)

type Theme

Theme defines the method to look up colors, sizes and fonts that make up a Fyne theme.

Since: 2.0

type ThemeColorName

type ThemeColorName string

ThemeColorName is used to look up a colour based on its name.

Since: 2.0

type ThemeIconName

type ThemeIconName string

ThemeIconName is used to look up an icon based on its name.

Since: 2.0

type ThemeSizeName

type ThemeSizeName string

ThemeSizeName is used to look up a size based on its name.

Since: 2.0

type ThemeVariant

type ThemeVariant uint

ThemeVariant indicates a variation of a theme, such as light or dark.

Since: 2.0

type URI

type URI interface {
	fmt.Stringer

	// Extension should return the file extension of the resource
	// (including the dot) referenced by the URI. For example, the
	// Extension() of 'file://foo/bar.baz' is '.baz'. May return an
	// empty string if the referenced resource has none.
	Extension() string

	// Name should return the base name of the item referenced by the URI.
	// For example, the Name() of 'file://foo/bar.baz' is 'bar.baz'.
	Name() string

	// MimeType should return the content type of the resource referenced
	// by the URI. The returned string should be in the format described
	// by Section 5 of RFC2045 ("Content-Type Header Field").
	MimeType() string

	// Scheme should return the URI scheme of the URI as defined by IETF
	// RFC3986. For example, the Scheme() of 'file://foo/bar.baz` is
	// 'file'.
	//
	// Scheme should always return the scheme in all lower-case characters.
	Scheme() string

	// Authority should return the URI authority, as defined by IETF
	// RFC3986.
	//
	// NOTE: the RFC3986 can be obtained by combining the User and Host
	// Fields of net/url's URL structure. Consult IETF RFC3986, section
	// 3.2, pp. 17.
	//
	// Since: 2.0
	Authority() string

	// Path should return the URI path, as defined by IETF RFC3986.
	//
	// Since: 2.0
	Path() string

	// Query should return the URI query, as defined by IETF RFC3986.
	//
	// Since: 2.0
	Query() string

	// Fragment should return the URI fragment, as defined by IETF
	// RFC3986.
	//
	// Since: 2.0
	Fragment() string
}

URI represents the identifier of a resource on a target system. This resource may be a file or another data source such as an app or file sharing system.

In general, it is expected that URI implementations follow IETF RFC3896. Implementations are highly recommended to utilize net/url to implement URI parsing methods, especially Scheme(), AUthority(), Path(), Query(), and Fragment().

type URIReadCloser

type URIReadCloser interface {
	io.ReadCloser

	URI() URI
}

URIReadCloser represents a cross platform data stream from a file or provider of data. It may refer to an item on a filesystem or data in another application that we have access to.

type URIWriteCloser

type URIWriteCloser interface {
	io.WriteCloser

	URI() URI
}

URIWriteCloser represents a cross platform data writer for a file resource. This will normally refer to a local file resource.

type Validatable

type Validatable interface {
	Validate() error

	// SetOnValidationChanged is used to set the callback that will be triggered when the validation state changes.
	// The function might be overwritten by a parent that cares about child validation (e.g. widget.Form).
	SetOnValidationChanged(func(error))
}

Validatable is an interface for specifying if a widget is validatable.

Since: 1.4

type Vector2

type Vector2 interface {
	Components() (float32, float32)
	IsZero() bool
}

Vector2 marks geometry types that can operate as a coordinate vector.

type Widget

type Widget interface {
	CanvasObject

	// CreateRenderer returns a new WidgetRenderer for this widget.
	// This should not be called by regular code, it is used internally to render a widget.
	CreateRenderer() WidgetRenderer
}

Widget defines the standard behaviours of any widget. This extends the CanvasObject - a widget behaves in the same basic way but will encapsulate many child objects to create the rendered widget.

type WidgetRenderer

type WidgetRenderer interface {
	// Destroy is for internal use.
	Destroy()
	// Layout is a hook that is called if the widget needs to be laid out.
	// This should never call Refresh.
	Layout(Size)
	// MinSize returns the minimum size of the widget that is rendered by this renderer.
	MinSize() Size
	// Objects returns all objects that should be drawn.
	Objects() []CanvasObject
	// Refresh is a hook that is called if the widget has updated and needs to be redrawn.
	// This might trigger a Layout.
	Refresh()
}

WidgetRenderer defines the behaviour of a widget's implementation. This is returned from a widget's declarative object through the CreateRenderer() function and should be exactly one instance per widget in memory.

type Window

type Window interface {
	// Title returns the current window title.
	// This is typically displayed in the window decorations.
	Title() string
	// SetTitle updates the current title of the window.
	SetTitle(string)

	// FullScreen returns whether or not this window is currently full screen.
	FullScreen() bool
	// SetFullScreen changes the requested fullScreen property
	// true for a fullScreen window and false to unset this.
	SetFullScreen(bool)

	// Resize this window to the requested content size.
	// The result may not be exactly as desired due to various desktop or
	// platform constraints.
	Resize(Size)

	// RequestFocus attempts to raise and focus this window.
	// This should only be called when you are sure the user would want this window
	// to steal focus from any current focused window.
	RequestFocus()

	// FixedSize returns whether or not this window should disable resizing.
	FixedSize() bool
	// SetFixedSize sets a hint that states whether the window should be a fixed
	// size or allow resizing.
	SetFixedSize(bool)

	// CenterOnScreen places a window at the center of the monitor
	// the Window object is currently positioned on.
	CenterOnScreen()

	// Padded, normally true, states whether the window should have inner
	// padding so that components do not touch the window edge.
	Padded() bool
	// SetPadded allows applications to specify that a window should have
	// no inner padding. Useful for fullscreen or graphic based applications.
	SetPadded(bool)

	// Icon returns the window icon, this is used in various ways
	// depending on operating system.
	// Most commonly this is displayed on the window border or task switcher.
	Icon() Resource

	// SetIcon sets the icon resource used for this window.
	// If none is set should return the application icon.
	SetIcon(Resource)

	// SetMaster indicates that closing this window should exit the app
	SetMaster()

	// MainMenu gets the content of the window's top level menu.
	MainMenu() *MainMenu

	// SetMainMenu adds a top level menu to this window.
	// The way this is rendered will depend on the loaded driver.
	SetMainMenu(*MainMenu)

	// SetOnClosed sets a function that runs when the window is closed.
	SetOnClosed(func())

	// SetCloseIntercept sets a function that runs instead of closing if defined.
	// Close() should be called explicitly in the interceptor to close the window.
	//
	// Since: 1.4
	SetCloseIntercept(func())

	// SetOnDropped allows setting a window-wide callback to receive dropped items.
	// The callback function is called with the absolute position of the drop and a
	// slice of all of the dropped URIs.
	//
	// Since 2.4
	SetOnDropped(func(Position, []URI))

	// Show the window on screen.
	Show()
	// Hide the window from the user.
	// This will not destroy the window or cause the app to exit.
	Hide()
	// Close the window.
	// If it is he "master" window the app will Quit.
	// If it is the only open window and no menu is set via [desktop.App]
	// SetSystemTrayMenu the app will also Quit.
	Close()

	// ShowAndRun is a shortcut to show the window and then run the application.
	// This should be called near the end of a main() function as it will block.
	ShowAndRun()

	// Content returns the content of this window.
	Content() CanvasObject
	// SetContent sets the content of this window.
	SetContent(CanvasObject)
	// Canvas returns the canvas context to render in the window.
	// This can be useful to set a key handler for the window, for example.
	Canvas() Canvas

	// Clipboard returns the system clipboard
	Clipboard() Clipboard
}

Window describes a user interface window. Depending on the platform an app may have many windows or just the one.

Directories

Path Synopsis
Package app provides app implementations for working with Fyne graphical interfaces.
Package app provides app implementations for working with Fyne graphical interfaces.
Package canvas contains all of the primitive CanvasObjects that make up a Fyne GUI.
Package canvas contains all of the primitive CanvasObjects that make up a Fyne GUI.
cmd
fyne
Run a command line helper for various Fyne tools.
Run a command line helper for various Fyne tools.
fyne/commands
Package commands provides functionality for managing fyne packages and the build process
Package commands provides functionality for managing fyne packages and the build process
fyne/internal/mobile
Package mobile is a partial clone of the golang.org/x/mobile/cmd/gomobile package.
Package mobile is a partial clone of the golang.org/x/mobile/cmd/gomobile package.
fyne/internal/mobile/binres
Package binres implements encoding and decoding of android binary resources.
Package binres implements encoding and decoding of android binary resources.
fyne_demo
Package main provides various examples of Fyne API capabilities.
Package main provides various examples of Fyne API capabilities.
hello
Package main loads a very basic Hello World graphical application.
Package main loads a very basic Hello World graphical application.
Package container provides containers that are used to lay out and organise applications.
Package container provides containers that are used to lay out and organise applications.
data
binding
Package binding provides support for binding data to widgets.
Package binding provides support for binding data to widgets.
validation
Package validation provides validation for data inside widgets.
Package validation provides validation for data inside widgets.
Package dialog defines standard dialog windows for application GUIs.
Package dialog defines standard dialog windows for application GUIs.
desktop
Package desktop provides desktop specific driver functionality.
Package desktop provides desktop specific driver functionality.
mobile
Package mobile provides mobile specific driver functionality.
Package mobile provides mobile specific driver functionality.
app
async
Package async provides unbounded channel and queue structures that are designed for caching unlimited number of a concrete type.
Package async provides unbounded channel and queue structures that are designed for caching unlimited number of a concrete type.
driver/glfw
Package glfw provides a full Fyne desktop driver that uses the system OpenGL libraries.
Package glfw provides a full Fyne desktop driver that uses the system OpenGL libraries.
driver/mobile/app
Package app lets you write portable all-Go apps for Android and iOS.
Package app lets you write portable all-Go apps for Android and iOS.
driver/mobile/event/key
Package key defines an event for physical keyboard keys.
Package key defines an event for physical keyboard keys.
driver/mobile/event/lifecycle
Package lifecycle defines an event for an app's lifecycle.
Package lifecycle defines an event for an app's lifecycle.
driver/mobile/event/paint
Package paint defines an event for the app being ready to paint.
Package paint defines an event for the app being ready to paint.
driver/mobile/event/size
Package size defines an event for the dimensions, physical resolution and orientation of the app's window.
Package size defines an event for the dimensions, physical resolution and orientation of the app's window.
driver/mobile/event/touch
Package touch defines an event for touch input.
Package touch defines an event for touch input.
driver/mobile/gl
Package gl implements Go bindings for OpenGL ES 2.0 and ES 3.0.
Package gl implements Go bindings for OpenGL ES 2.0 and ES 3.0.
driver/mobile/mobileinit
Package mobileinit contains common initialization logic for mobile platforms that is relevant to both all-Go apps and gobind-based apps.
Package mobileinit contains common initialization logic for mobile platforms that is relevant to both all-Go apps and gobind-based apps.
painter/gl
Package gl provides a full Fyne render implementation using system OpenGL libraries.
Package gl provides a full Fyne render implementation using system OpenGL libraries.
svg
Package layout defines the various layouts available to Fyne apps.
Package layout defines the various layouts available to Fyne apps.
Package storage provides storage access and management functionality.
Package storage provides storage access and management functionality.
repository
Package repository provides primitives for working with storage repositories.
Package repository provides primitives for working with storage repositories.
Package test provides utility drivers for running UI tests without rendering to a screen.
Package test provides utility drivers for running UI tests without rendering to a screen.
Package theme defines how a Fyne app should look when rendered.
Package theme defines how a Fyne app should look when rendered.
tools
playground
Package playground provides tooling for running fyne applications inside the Go playground.
Package playground provides tooling for running fyne applications inside the Go playground.
Package widget defines the UI widgets within the Fyne toolkit.
Package widget defines the UI widgets within the Fyne toolkit.

Jump to

Keyboard shortcuts

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