Documentation
¶
Overview ¶
Package app contains an API for working with an application window and the relevant input / output mechanisms that go with it.
Index ¶
- Variables
- type ClipboardEvent
- type Controller
- type Cursor
- type CursorDefinition
- type Environment
- type FilepathPayload
- type Gamepad
- type GamepadAction
- type GamepadButton
- type GamepadEvent
- type GamepadStick
- type KeyCode
- type KeyboardAction
- type KeyboardEvent
- type LayeredController
- func (c *LayeredController) OnClipboardEvent(window Window, event ClipboardEvent) bool
- func (c *LayeredController) OnCloseRequested(window Window) bool
- func (c *LayeredController) OnCreate(window Window)
- func (c *LayeredController) OnDestroy(window Window)
- func (c *LayeredController) OnFramebufferResize(window Window, width, height int)
- func (c *LayeredController) OnGamepadEvent(window Window, event GamepadEvent) bool
- func (c *LayeredController) OnKeyboardEvent(window Window, event KeyboardEvent) bool
- func (c *LayeredController) OnMouseEvent(window Window, event MouseEvent) bool
- func (c *LayeredController) OnRender(window Window)
- func (c *LayeredController) OnResize(window Window, width, height int)
- type MouseAction
- type MouseButton
- type MouseEvent
- type NopController
- func (NopController) OnClipboardEvent(window Window, event ClipboardEvent) bool
- func (NopController) OnCloseRequested(window Window) bool
- func (NopController) OnCreate(window Window)
- func (NopController) OnDestroy(window Window)
- func (NopController) OnFramebufferResize(window Window, width, height int)
- func (NopController) OnGamepadEvent(window Window, event GamepadEvent) bool
- func (NopController) OnKeyboardEvent(window Window, event KeyboardEvent) bool
- func (NopController) OnMouseEvent(window Window, event MouseEvent) bool
- func (NopController) OnRender(window Window)
- func (NopController) OnResize(window Window, width, height int)
- type OS
- type Platform
- type Window
Constants ¶
This section is empty.
Variables ¶
var ( // GamepadMinEventInterval is the minimum interval between // gamepad event processing. This is to ensure that even if there are no // native events, the gamepad will still produce events. // // This value can be changed from the UI thread. GamepadMinEventInterval = 30 * time.Millisecond // GamepadRepeatDelay is the initial delay before a held down // gamepad button starts repeating. // // This value can be changed from the UI thread. GamepadRepeatDelay = 600 * time.Millisecond // GamepadRepeatInterval is the interval between repeated // gamepad button events after the initial delay. // // This value can be changed from the UI thread. GamepadRepeatInterval = 100 * time.Millisecond )
Functions ¶
This section is empty.
Types ¶
type ClipboardEvent ¶ added in v0.13.0
type ClipboardEvent struct {
// Text holds the text stored in the clipboard.
Text string
}
ClipboardEvent holds information related to the clipboard content.
type Controller ¶
type Controller interface {
// OnCreate is called when the window has been created and is
// ready to be used.
OnCreate(window Window)
// OnResize is called when the window's content area has been
// resized.
OnResize(window Window, width, height int)
// OnFramebufferResize is called when the window's framebuffer has
// been resized.
// Note that the framebuffer need not match the content size. This
// is mostly the case on devices with a high DPI setting.
OnFramebufferResize(window Window, width, height int)
// OnKeyboardEvent is called whenever a keyboard event has occurred.
//
// Return true to indicate that the event has been consumed and should
// not be propagated to other potential receivers, otherwise return false.
OnKeyboardEvent(window Window, event KeyboardEvent) bool
// OnMouseEvent is called whenever a mouse event has occurred.
//
// Return true to indicate that the event has been consumed and should
// not be propagated to other potential receivers, otherwise return false.
OnMouseEvent(window Window, event MouseEvent) bool
// OnGamepadEvent is called whenever a gamepad event has occurred.
//
// Return true to indicate that the event has been consumed and should
// not be propagated to other potential receivers, otherwise return false.
OnGamepadEvent(window Window, event GamepadEvent) bool
// OnClipboardEvent is called whenever the clipboard content has been
// requested and the underlying window has managed to retrieve it.
//
// Return true to indicate that the event has been consumed and should
// not be propagated to other potential receivers, otherwise return false.
OnClipboardEvent(window Window, event ClipboardEvent) bool
// OnRender is called whenever the window would like to be redrawn.
OnRender(window Window)
// OnCloseRequested is called whenever the end-user has requested
// that the application be closed through the native OS means
// (e.g. pressing the close button or ALT+F4).
//
// Unlike regular events, returning false from this function indicates
// that the operation should not be performed. Furthermore, the event will
// not be passed to other potential receivers.
//
// Note that on some platforms (e.g. browser) returning false may invoke
// a native warning dialog.
OnCloseRequested(window Window) bool
// OnDestroy is called before the window is closed.
OnDestroy(window Window)
}
Controller is a mechanism through which the user code can be notified of changes to the application window.
All methods will be invoked on the UI thread (UI goroutine), unless otherwise specified.
type Cursor ¶
type Cursor interface {
// Destroy releases all resources allocated for this cursor.
Destroy()
}
Cursor represents the visual aspect of a pointer on the screen.
type CursorDefinition ¶
type CursorDefinition struct {
// Path specifies the location of the image resource.
Path string
// HotspotX specifies the X click position within the cursor image.
HotspotX int
// HotspotY specifies the Y click position within the cursor image.
HotspotY int
}
CursorDefinition can be used to describe a new cursor.
type Environment ¶ added in v0.13.0
type Environment string
Environment represents the environment in which the app runs.
const ( // EnvironmentNative indicates a native app binary. EnvironmentNative Environment = "NATIVE" // EnvironmentBrowser indicates a browser page. EnvironmentBrowser Environment = "BROWSER" )
type FilepathPayload ¶ added in v0.3.0
type FilepathPayload struct {
// Paths contains file paths to the dropped resources.
Paths []string
}
FilepathPayload is a type of Payload that occurs when files have been dragged and dropped onto the window.
type Gamepad ¶ added in v0.10.0
type Gamepad interface {
// Connected returns whether this Gamepad is still connected. This is
// useful for when a Gamepad instance is kept by the user code.
Connected() bool
// Supported returns whether the connected device can be mapped to the
// standard layout:
// https://w3c.github.io/gamepad/#remapping
//
// Devices that are not supported will return zero values for buttons
// and axes.
Supported() bool
// StickDeadzone returns the range around 0.0 that will not be considered
// valid for stick motion.
StickDeadzone() float64
// SetStickDeadzone changes the deadzone range for sticks.
SetStickDeadzone(deadzone float64)
// TriggerDeadzone returns the range around 0.0 that will not be considered
// valid for trigger motion.
TriggerDeadzone() float64
// SetTriggerDeadzone changes the deadzone range for triggers.
SetTriggerDeadzone(deadzone float64)
// LeftStickX returns the horizontal axis of the left stick.
LeftStickX() float64
// LeftStickY returns the vertical axis of the left stick.
LeftStickY() float64
// LeftStickButton returns the button represented by pressing
// on the left stick.
LeftStickButton() bool
// RightStickX returns the horizontal axis of the right stick.
RightStickX() float64
// RightStickY returns the vertical axis of the right stick.
RightStickY() float64
// RightStickButton returns the button represented by pressing
// on the right stick.
RightStickButton() bool
// LeftTrigger returns the analog value of the left trigger.
LeftTrigger() float64
// RightTrigger returns the analog value of the right trigger.
RightTrigger() float64
// LeftBumper returns the left bumper button.
LeftBumper() bool
// RightBumper returns the right bumper button.
RightBumper() bool
// DpadUpButton returns the up button of the left cluster.
DpadUpButton() bool
// DpadDownButton returns the down button of the left cluster.
DpadDownButton() bool
// DpadLeftButton returns the left button of the left cluster.
DpadLeftButton() bool
// DpadRightButton returns the right button of the left cluster.
DpadRightButton() bool
// ActionUpButton returns the up button of the right cluster.
ActionUpButton() bool
// ActionDownButton returns the down button of the right cluster.
ActionDownButton() bool
// ActionLeftButton returns the left button of the right cluster.
ActionLeftButton() bool
// ActionRightButton returns the right button of the right cluster.
ActionRightButton() bool
// ForwardButton returns the right button of the center cluster.
ForwardButton() bool
// BackButton returns the left button of the center cluster.
BackButton() bool
// Pulse causes the Gamepad controller to vibrate with the specified
// intensity for the specified duration. The intensity should be within the
// range [0.0, 1.0] - a value outside that range will be clamped.
//
// If the device does not have haptic feedback or if this API implementation
// does not support it then this method does nothing.
Pulse(intensity float64, duration time.Duration)
}
Gamepad represents a gamepad-type joystick. Only input devices that can be mapped according to standard layout will work and have any axis and button output.
type GamepadAction ¶ added in v0.23.0
type GamepadAction int
GamepadAction is used to specify the type of gamepad action that occurred.
const ( // GamepadActionNone indicates that no action occurred. This is an unlikely // value but allows for more custom event situations. GamepadActionNone GamepadAction = iota // GamepadActionConnected indicates that the gamepad was connected. GamepadActionConnected // GamepadActionDisconnected indicates that the gamepad was disconnected. GamepadActionDisconnected // GamepadActionButtonDown indicates that a gamepad button was pressed down. GamepadActionButtonDown // GamepadActionButtonUp indicates that a gamepad button was released. GamepadActionButtonUp // GamepadActionButtonRepeat indicates that a gamepad button is being held // down and is repeating. GamepadActionButtonRepeat // GamepadActionStickMove indicates that a gamepad stick or trigger was moved. GamepadActionStickMove // GamepadActionCount is a sentinel value representing the total number of // gamepad action enums. GamepadActionCount )
func (GamepadAction) String ¶ added in v0.23.0
func (s GamepadAction) String() string
String returns a string representation of this event type.
type GamepadButton ¶ added in v0.23.0
type GamepadButton int
GamepadButton represents the gamepad button.
const ( // GamepadButtonNone indicates that no button is associated with the event. GamepadButtonNone GamepadButton = iota // GamepadButtonLeftStick indicates the button represented by pressing // on the left stick. GamepadButtonLeftStick // GamepadButtonRightStick indicates the button represented by pressing // on the right stick. GamepadButtonRightStick // GamepadButtonLeftTrigger indicates the left trigger viewed as a button. GamepadButtonLeftTrigger // GamepadButtonRightTrigger indicates the right trigger viewed as a button. GamepadButtonRightTrigger // GamepadButtonLeftBumper indicates the left bumper button. GamepadButtonLeftBumper // GamepadButtonRightBumper indicates the right bumper button. GamepadButtonRightBumper // GamepadButtonDpadUp indicates the up button of the left cluster. GamepadButtonDpadUp // GamepadButtonDpadDown indicates the down button of the left cluster. GamepadButtonDpadDown // GamepadButtonDpadLeft indicates the left button of the left cluster. GamepadButtonDpadLeft // GamepadButtonDpadRight indicates the right button of the left cluster. GamepadButtonDpadRight // GamepadButtonActionUp indicates the up button of the right cluster. GamepadButtonActionUp // GamepadButtonActionDown indicates the down button of the right cluster. GamepadButtonActionDown // GamepadButtonActionLeft indicates the left button of the right cluster. GamepadButtonActionLeft // GamepadButtonActionRight indicates the right button of the right cluster. GamepadButtonActionRight // GamepadButtonForward indicates the right button of the center cluster. GamepadButtonForward // GamepadButtonBack indicates the left button of the center cluster. GamepadButtonBack // GamepadButtonLeftStickUp indicates the up direction on the left stick. GamepadButtonLeftStickUp // GamepadButtonLeftStickDown indicates the down direction on the left stick. GamepadButtonLeftStickDown // GamepadButtonLeftStickLeft indicates the left direction on the left stick. GamepadButtonLeftStickLeft // GamepadButtonLeftStickRight indicates the right direction on the left // stick. GamepadButtonLeftStickRight // GamepadButtonRightStickUp indicates the up direction on the right stick. GamepadButtonRightStickUp // GamepadButtonRightStickDown indicates the down direction on the right // stick. GamepadButtonRightStickDown // GamepadButtonRightStickLeft indicates the left direction on the right // stick. GamepadButtonRightStickLeft // GamepadButtonRightStickRight indicates the right direction on the right // stick. GamepadButtonRightStickRight // GamepadButtonCount is a sentinel value representing the total number of // gamepad button enums. GamepadButtonCount )
func (GamepadButton) String ¶ added in v0.23.0
func (b GamepadButton) String() string
String returns a string representation of this button.
type GamepadEvent ¶ added in v0.23.0
type GamepadEvent struct {
// Index indicates which gamepad triggered the event. By default
// the index for the primary gamepad is 0.
Index int
// Gamepad is a reference to the gamepad that triggered the event.
Gamepad Gamepad
// Action indicates the action performed with the gamepad.
Action GamepadAction
// Button specifies the button for which an event occurred. This is only
// applicable for button events.
Button GamepadButton
// Stick specifies the stick for which an event occurred. This is only
// applicable for stick move events.
Stick GamepadStick
// X specifies the horizontal position of the stick.
X float64
// Y specifies the vertical position of the stick.
Y float64
}
GamepadEvent represents an event related to a gamepad action.
func (GamepadEvent) String ¶ added in v0.23.0
func (s GamepadEvent) String() string
String returns a string representation of this event.
type GamepadStick ¶ added in v0.23.0
type GamepadStick int
GamepadStick is used to specify a particular stick on the gamepad.
const ( // GamepadStickNone indicates that no axis is associated with the event. GamepadStickNone GamepadStick = iota // GamepadStickLeft indicates the left stick. GamepadStickLeft // GamepadStickRight indicates the right stick. GamepadStickRight // GamepadStickLeftTrigger indicates the left trigger. // Only the Y stick value is applicable and is within the range [0.0, 1.0]. GamepadStickLeftTrigger // GamepadStickRightTrigger indicates the right trigger. // Only the Y stick value is applicable and is within the range [0.0, 1.0]. GamepadStickRightTrigger // GamepadStickCount is a sentinel value representing the total number of // gamepad stick enums. GamepadStickCount )
func (GamepadStick) String ¶ added in v0.23.0
func (s GamepadStick) String() string
String returns a string representation of this stick.
type KeyCode ¶
type KeyCode int
KeyCode represents a keyboard key.
const ( // KeyCodeNone indicates that no key is associated with the event. KeyCodeNone KeyCode = iota // KeyCodeEscape indicates the Escape key. KeyCodeEscape // KeyCodeEnter indicates the Enter key. KeyCodeEnter // KeyCodeSpace indicates the Space key. KeyCodeSpace // KeyCodeTab indicates the Tab key. KeyCodeTab // KeyCodeCaps indicates the Caps Lock key. KeyCodeCaps // KeyCodeLeftShift indicates the left Shift key. KeyCodeLeftShift // KeyCodeRightShift indicates the right Shift key. KeyCodeRightShift // KeyCodeLeftControl indicates the left Control key. KeyCodeLeftControl // KeyCodeRightControl indicates the right Control key. KeyCodeRightControl // KeyCodeLeftAlt indicates the left Alt key. KeyCodeLeftAlt // KeyCodeRightAlt indicates the right Alt key. KeyCodeRightAlt // KeyCodeLeftSuper indicates the left Super (Win/Cmd) key. KeyCodeLeftSuper // KeyCodeRightSuper indicates the right Super (Win/Cmd) key. KeyCodeRightSuper // KeyCodeBackspace indicates the Backspace key. KeyCodeBackspace // KeyCodeInsert indicates the Insert key. KeyCodeInsert // KeyCodeDelete indicates the Delete key. KeyCodeDelete // KeyCodeHome indicates the Home key. KeyCodeHome // KeyCodeEnd indicates the End key. KeyCodeEnd // KeyCodePageUp indicates the Page Up key. KeyCodePageUp // KeyCodePageDown indicates the Page Down key. KeyCodePageDown // KeyCodeArrowLeft indicates the left arrow key. KeyCodeArrowLeft // KeyCodeArrowRight indicates the right arrow key. KeyCodeArrowRight // KeyCodeArrowUp indicates the up arrow key. KeyCodeArrowUp // KeyCodeArrowDown indicates the down arrow key. KeyCodeArrowDown // KeyCodeMinus indicates the minus/hyphen key. KeyCodeMinus // KeyCodeEqual indicates the equal sign key. KeyCodeEqual // KeyCodeLeftBracket indicates the left square bracket key. KeyCodeLeftBracket // KeyCodeRightBracket indicates the right square bracket key. KeyCodeRightBracket // KeyCodeSemicolon indicates the semicolon key. KeyCodeSemicolon // KeyCodeComma indicates the comma key. KeyCodeComma // KeyCodePeriod indicates the period/full stop key. KeyCodePeriod // KeyCodeSlash indicates the forward slash key. KeyCodeSlash // KeyCodeBackslash indicates the backslash key. KeyCodeBackslash // KeyCodeApostrophe indicates the apostrophe/single-quote key. KeyCodeApostrophe // KeyCodeGraveAccent indicates the grave accent/backtick key. KeyCodeGraveAccent // KeyCodeA indicates the A key. KeyCodeA // KeyCodeB indicates the B key. KeyCodeB // KeyCodeC indicates the C key. KeyCodeC // KeyCodeD indicates the D key. KeyCodeD // KeyCodeE indicates the E key. KeyCodeE // KeyCodeF indicates the F key. KeyCodeF // KeyCodeG indicates the G key. KeyCodeG // KeyCodeH indicates the H key. KeyCodeH // KeyCodeI indicates the I key. KeyCodeI // KeyCodeJ indicates the J key. KeyCodeJ // KeyCodeK indicates the K key. KeyCodeK // KeyCodeL indicates the L key. KeyCodeL // KeyCodeM indicates the M key. KeyCodeM // KeyCodeN indicates the N key. KeyCodeN // KeyCodeO indicates the O key. KeyCodeO // KeyCodeP indicates the P key. KeyCodeP // KeyCodeQ indicates the Q key. KeyCodeQ // KeyCodeR indicates the R key. KeyCodeR // KeyCodeS indicates the S key. KeyCodeS // KeyCodeT indicates the T key. KeyCodeT // KeyCodeU indicates the U key. KeyCodeU // KeyCodeV indicates the V key. KeyCodeV // KeyCodeW indicates the W key. KeyCodeW // KeyCodeX indicates the X key. KeyCodeX // KeyCodeY indicates the Y key. KeyCodeY // KeyCodeZ indicates the Z key. KeyCodeZ // KeyCode0 indicates the 0 key. KeyCode0 // KeyCode1 indicates the 1 key. KeyCode1 // KeyCode2 indicates the 2 key. KeyCode2 // KeyCode3 indicates the 3 key. KeyCode3 // KeyCode4 indicates the 4 key. KeyCode4 // KeyCode5 indicates the 5 key. KeyCode5 // KeyCode6 indicates the 6 key. KeyCode6 // KeyCode7 indicates the 7 key. KeyCode7 // KeyCode8 indicates the 8 key. KeyCode8 // KeyCode9 indicates the 9 key. KeyCode9 // KeyCodeF1 indicates the F1 function key. KeyCodeF1 // KeyCodeF2 indicates the F2 function key. KeyCodeF2 // KeyCodeF3 indicates the F3 function key. KeyCodeF3 // KeyCodeF4 indicates the F4 function key. KeyCodeF4 // KeyCodeF5 indicates the F5 function key. KeyCodeF5 // KeyCodeF6 indicates the F6 function key. KeyCodeF6 // KeyCodeF7 indicates the F7 function key. KeyCodeF7 // KeyCodeF8 indicates the F8 function key. KeyCodeF8 // KeyCodeF9 indicates the F9 function key. KeyCodeF9 // KeyCodeF10 indicates the F10 function key. KeyCodeF10 // KeyCodeF11 indicates the F11 function key. KeyCodeF11 // KeyCodeF12 indicates the F12 function key. KeyCodeF12 // KeyCodeCount is a sentinel value representing the total number of // key code enums. KeyCodeCount )
type KeyboardAction ¶ added in v0.13.0
type KeyboardAction int
KeyboardAction is used to specify the type of keyboard action that occurred.
const ( // KeyboardActionNone indicates that no keyboard action is taking place. KeyboardActionNone KeyboardAction = iota // KeyboardActionDown indicates that a keyboard key was pressed. KeyboardActionDown // KeyboardActionUp indicates that a keyboard key was released. KeyboardActionUp // KeyboardActionRepeat indicates that a keyboard key is being held pressed. KeyboardActionRepeat // KeyboardActionType indicates that a character is typed with the keyboard. // // Such actions would be duplicates of KeyboardActionDown and // KeyboardActionRepeat but allow for the character rune to be read which // might be the result of modifiers or special keys that would be hard // to reconstruct from just the key code. KeyboardActionType // KeyboardActionCount is a sentinel value representing the total number of // keyboard action enums. KeyboardActionCount )
func (KeyboardAction) String ¶ added in v0.13.0
func (a KeyboardAction) String() string
String returns a string representation of this event type.
type KeyboardEvent ¶
type KeyboardEvent struct {
// Action specifies the keyboard event type.
Action KeyboardAction
// Code returns the code of the keyboard key.
Code KeyCode
// Character returns the character that was typed in case
// of a KeyboardActionType event.
Character rune
}
KeyboardEvent is used to propagate events related to keyboard actions.
func (KeyboardEvent) String ¶ added in v0.13.0
func (e KeyboardEvent) String() string
String returns a string representation of this event.
type LayeredController ¶
type LayeredController struct {
// contains filtered or unexported fields
}
LayeredController is an implementation of Controller that invokes the specified controller layers in an order emulating multiple overlays of a window.
Lifecycle methods (OnCreate, OnResize, OnFramebufferResize, OnRender) are called in forward order (first layer first). OnDestroy is called in reverse order so that layers are torn down in the opposite order to their creation. Event methods (OnKeyboardEvent, OnMouseEvent, OnGamepadEvent, OnClipboardEvent, OnCloseRequested) are called in reverse order so that the top-most layer gets first opportunity to consume the event.
func NewLayeredController ¶
func NewLayeredController(layers ...Controller) *LayeredController
NewLayeredController returns a new LayeredController that has the specified controller layers configured.
func (*LayeredController) OnClipboardEvent ¶ added in v0.13.0
func (c *LayeredController) OnClipboardEvent(window Window, event ClipboardEvent) bool
func (*LayeredController) OnCloseRequested ¶
func (c *LayeredController) OnCloseRequested(window Window) bool
func (*LayeredController) OnCreate ¶
func (c *LayeredController) OnCreate(window Window)
func (*LayeredController) OnDestroy ¶
func (c *LayeredController) OnDestroy(window Window)
func (*LayeredController) OnFramebufferResize ¶
func (c *LayeredController) OnFramebufferResize(window Window, width, height int)
func (*LayeredController) OnGamepadEvent ¶ added in v0.23.0
func (c *LayeredController) OnGamepadEvent(window Window, event GamepadEvent) bool
func (*LayeredController) OnKeyboardEvent ¶
func (c *LayeredController) OnKeyboardEvent(window Window, event KeyboardEvent) bool
func (*LayeredController) OnMouseEvent ¶
func (c *LayeredController) OnMouseEvent(window Window, event MouseEvent) bool
func (*LayeredController) OnRender ¶
func (c *LayeredController) OnRender(window Window)
func (*LayeredController) OnResize ¶
func (c *LayeredController) OnResize(window Window, width, height int)
type MouseAction ¶ added in v0.13.0
type MouseAction int
MouseAction represents the type of action performed with the mouse.
const ( // MouseActionNone indicates that no mouse action occurred. MouseActionNone MouseAction = iota // MouseActionDown indicates that a mouse button was pressed down. MouseActionDown // MouseActionUp indicates that a mouse button was released. MouseActionUp // MouseActionMove indicates that the mouse was moved. MouseActionMove // MouseActionEnter indicates that the mouse has entered the window. MouseActionEnter // MouseActionLeave indicates that the mouse has left the window. // // If the mouse was being dragged, further events may be sent from outside // the window boundary. MouseActionLeave // MouseActionDrop indicates that some payload was dropped onto the window. MouseActionDrop // MouseActionScroll indicates that the mouse wheel was scrolled. // // The ScrollX and ScrollY values of the event indicate the offset in // abstract units (comparable to pixels in magnitude). MouseActionScroll // MouseActionCount is a sentinel value representing the total number of // mouse action enums. MouseActionCount )
func (MouseAction) String ¶ added in v0.13.0
func (a MouseAction) String() string
String returns a string representation of this event type.
type MouseButton ¶
type MouseButton int
MouseButton represents the mouse button.
const ( // MouseButtonNone indicates that no mouse button is involved. MouseButtonNone MouseButton = iota // MouseButtonLeft specifies the left mouse button. MouseButtonLeft // MouseButtonMiddle specifies the middle mouse button. MouseButtonMiddle // MouseButtonRight specifies the right mouse button. MouseButtonRight // MouseButtonCount is a sentinel value representing the total number of // mouse button enums. MouseButtonCount )
func (MouseButton) String ¶
func (b MouseButton) String() string
String returns a string representation of this button.
type MouseEvent ¶
type MouseEvent struct {
// Index indicates which mouse triggered the event. By default
// the index for the primary mouse is 0.
//
// This is applicable for devices with multiple pointers
// (mobile) or in case a second mouse is emulated
// (e.g. with a game controller).
Index int
// Action indicates the action performed with the mouse.
Action MouseAction
// Button specifies the button for which the event is applicable.
Button MouseButton
// X specifies the horizontal position of the mouse.
X int
// Y specifies the vertical position of the mouse.
Y int
// ScrollX determines the amount of horizontal scroll.
ScrollX float64
// ScrollY determines the amount of vertical scroll.
ScrollY float64
// Payload contains any external data associated with the event.
Payload any
}
MouseEvent represents an event related to a mouse action.
func (MouseEvent) String ¶
func (e MouseEvent) String() string
String returns a string representation of this event.
type NopController ¶
type NopController struct{}
NopController is a no-op implementation of a Controller.
func (NopController) OnClipboardEvent ¶ added in v0.13.0
func (NopController) OnClipboardEvent(window Window, event ClipboardEvent) bool
func (NopController) OnCloseRequested ¶
func (NopController) OnCloseRequested(window Window) bool
func (NopController) OnCreate ¶
func (NopController) OnCreate(window Window)
func (NopController) OnDestroy ¶
func (NopController) OnDestroy(window Window)
func (NopController) OnFramebufferResize ¶
func (NopController) OnFramebufferResize(window Window, width, height int)
func (NopController) OnGamepadEvent ¶ added in v0.23.0
func (NopController) OnGamepadEvent(window Window, event GamepadEvent) bool
func (NopController) OnKeyboardEvent ¶
func (NopController) OnKeyboardEvent(window Window, event KeyboardEvent) bool
func (NopController) OnMouseEvent ¶
func (NopController) OnMouseEvent(window Window, event MouseEvent) bool
func (NopController) OnRender ¶
func (NopController) OnRender(window Window)
func (NopController) OnResize ¶
func (NopController) OnResize(window Window, width, height int)
type OS ¶ added in v0.13.0
type OS string
OS represents the operating system that runs the application regardless if native or via an intermediary like a browser.
const ( // OSLinux indicates the Linux operating system. OSLinux OS = "LINUX" // OSDarwin indicates the MacOS operating system. OSDarwin OS = "DARWIN" // OSWindows indicates the Windows operating system. OSWindows OS = "WINDOWS" // OSUnknown indicates that the operating system could not be determined. OSUnknown OS = "UNKNOWN" )
type Platform ¶ added in v0.13.0
type Platform interface {
// Environment returns the current environment.
Environment() Environment
// OS returns the current operating system.
OS() OS
}
Platform contains information on the system that is running the app.
type Window ¶
type Window interface {
// Platform returns the information on the platform that is running the app.
Platform() Platform
// Title returns this window's title.
Title() string
// SetTitle changes the title of this window.
SetTitle(title string)
// Size returns the content area of this window.
Size() (int, int)
// SetSize changes the content area of this window.
SetSize(width, height int)
// FramebufferSize returns the texel size of the underlying framebuffer.
// This would normally be used as reference when using graphics libraries
// to draw on the screen as the framebuffer size may differ from the
// window size.
FramebufferSize() (int, int)
// Gamepads returns an array of potentially available gamepad
// controllers.
//
// Use the Connected and Supported methods on the Gamepad object to check
// whether it is connected and can be used.
//
// This API supports up to 4 connected devices.
Gamepads() [4]Gamepad
// Schedule queues a function to be called on the UI thread
// when possible. There are no guarantees that it will necessarily
// be on the next frame iteration.
Schedule(fn func())
// Invalidate causes this window to be redrawn when possible.
Invalidate()
// CreateCursor creates a new cursor object based on the specified
// definition.
CreateCursor(definition CursorDefinition) Cursor
// UseCursor changes the currently displayed cursor on the screen.
// Specifying nil returns the default cursor.
UseCursor(cursor Cursor)
// CursorVisible returns whether a cursor is to be displayed on the
// screen. This is determined based on the visibility and lock settings
// of the cursor.
CursorVisible() bool
// SetCursorVisible changes whether a cursor is displayed on the
// screen.
SetCursorVisible(visible bool)
// CursorLocked returns whether the cursor is trapped within the
// boundaries of the window.
CursorLocked() bool
// SetCursorLocked traps the cursor within the boundaries of the window
// and reports relative motion events. This method also hides the cursor.
SetCursorLocked(locked bool)
// RequestCopy requests that the specified text be stored in the clipboard.
RequestCopy(text string)
// RequestPaste requests that the clipboard be read and the content be
// passed down through an event.
RequestPaste()
// RenderAPI provides access to a usable Render API based on the current
// window's screen.
//
// If the implementation of this API does not support graphics, then this
// method returns nil.
RenderAPI() render.API
// AudioAPI provides access to a usable Audio API based on the current
// window.
//
// If the implementation of this API does not support audio, then this
// method returns nil.
AudioAPI() audio.API
// Close disposes of this window.
Close()
}
Window represents a native application window.
All methods must be invoked on the UI thread (UI goroutine), unless otherwise specified.