web

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package web implements system interfaces on the web through WASM

Index

Constants

This section is empty.

Variables

View Source
var TheApp = &App{AppSingle: base.NewAppSingle[*Drawer, *Window]()}

TheApp is the single system.App for the web platform

View Source
var TheClipboard = &Clipboard{}

TheClipboard is the single system.Clipboard for the web platform

View Source
var TheCursor = &Cursor{CursorBase: system.CursorBase{Vis: true, Size: 32}}

TheCursor is the single system.Cursor for the web platform

Functions

func AddEventListener

func AddEventListener(v js.Value, nm string, fn func(this js.Value, args []js.Value) any, opts ...map[string]any)

func Init

func Init()

func UserAgentToOS

func UserAgentToOS(ua string) system.Platforms

UserAgentToOS converts the given user agent string to a system.Platforms value.

Types

type App

type App struct {
	base.AppSingle[*Drawer, *Window]

	// UnderlyingPlatform is the underlying system platform (Android, iOS, etc)
	UnderlyingPlatform system.Platforms

	// KeyMods are the current key mods
	KeyMods key.Modifiers
}

App is the system.App implementation for the web platform

func (*App) AddEventListeners

func (a *App) AddEventListeners()

func (*App) Clipboard

func (a *App) Clipboard(win system.Window) system.Clipboard

func (*App) Cursor

func (a *App) Cursor(win system.Window) system.Cursor

func (*App) DataDir

func (a *App) DataDir() string

func (*App) EventPos

func (a *App) EventPos(e js.Value) image.Point

EventPos returns the appropriate position for the given event, multiplying the x and y components by the device pixel ratio so that they line up correctly with the canvas.

func (*App) EventPosFor

func (a *App) EventPosFor(x, y js.Value) image.Point

EventPosFor transforms the given position by multiplying the x and y components by the device pixel ratio so that they line up correctly with the canvas.

func (*App) HideVirtualKeyboard

func (a *App) HideVirtualKeyboard()

func (*App) InitDrawer added in v0.3.2

func (a *App) InitDrawer()

InitDrawer sets the Drawer to a WebGPU-based drawer if the browser supports WebGPU and a backup 2D image drawer otherwise.

func (*App) IsDark

func (a *App) IsDark() bool

func (*App) NewWindow

func (a *App) NewWindow(opts *system.NewWindowOptions) (system.Window, error)

NewWindow creates a new window with the given options. It waits for the underlying system window to be created first. Also, it hides all other windows and shows the new one.

func (*App) OnBeforeInput

func (a *App) OnBeforeInput(this js.Value, args []js.Value) any

func (*App) OnBlur added in v0.3.1

func (a *App) OnBlur(this js.Value, args []js.Value) any

func (*App) OnContextMenu

func (a *App) OnContextMenu(this js.Value, args []js.Value) any

func (*App) OnKeyDown

func (a *App) OnKeyDown(this js.Value, args []js.Value) any

func (*App) OnKeyUp

func (a *App) OnKeyUp(this js.Value, args []js.Value) any

func (*App) OnMouseDown

func (a *App) OnMouseDown(this js.Value, args []js.Value) any

func (*App) OnMouseMove

func (a *App) OnMouseMove(this js.Value, args []js.Value) any

func (*App) OnMouseUp

func (a *App) OnMouseUp(this js.Value, args []js.Value) any

func (*App) OnResize

func (a *App) OnResize(this js.Value, args []js.Value) any

func (*App) OnTouchEnd

func (a *App) OnTouchEnd(this js.Value, args []js.Value) any

func (*App) OnTouchMove

func (a *App) OnTouchMove(this js.Value, args []js.Value) any

func (*App) OnTouchStart

func (a *App) OnTouchStart(this js.Value, args []js.Value) any

func (*App) OnWheel

func (a *App) OnWheel(this js.Value, args []js.Value) any

func (*App) OpenURL

func (a *App) OpenURL(url string)

func (*App) Platform

func (a *App) Platform() system.Platforms

func (*App) Resize

func (a *App) Resize()

Resize updates the app sizing information and sends a Resize event.

func (*App) RuneAndCodeFromKey

func (a *App) RuneAndCodeFromKey(k string, down bool) (rune, key.Codes)

RuneAndCodeFromKey returns the rune and key code corresponding to the given key string. down is whether this is from a keyDown event (as opposed to a keyUp one)

func (*App) SetSystemWindow

func (a *App) SetSystemWindow()

SetSystemWindow sets the underlying system window information.

func (*App) ShouldProcessKey added in v0.1.1

func (a *App) ShouldProcessKey(k string) bool

ShouldProcessKey returns whether the given key string should be processed by Cogent Core.

func (*App) ShowVirtualKeyboard

func (a *App) ShowVirtualKeyboard(typ styles.VirtualKeyboards)

func (*App) SystemInfo added in v0.2.0

func (a *App) SystemInfo() string

func (*App) SystemPlatform

func (a *App) SystemPlatform() system.Platforms

type Clipboard

type Clipboard struct {
	system.ClipboardBase
}

Clipboard is the system.Clipboard implementation for the web platform

func (*Clipboard) Read

func (cl *Clipboard) Read(types []string) mimedata.Mimes

func (*Clipboard) Write

func (cl *Clipboard) Write(data mimedata.Mimes) error

type Cursor

type Cursor struct {
	system.CursorBase
}

Cursor is the system.Cursor implementation for the web platform

func (*Cursor) Set

func (cu *Cursor) Set(cursor enums.Enum) error

type Drawer

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

Drawer implements system.Drawer with a WebGPU-based drawer if available and a backup 2D image drawer if not.

func (*Drawer) AsGPUDrawer added in v0.3.2

func (dw *Drawer) AsGPUDrawer() *gpudraw.Drawer

AsGPUDrawer implements gpudraw.AsGPUDrawer.

func (*Drawer) Copy added in v0.3.2

func (dw *Drawer) Copy(dp image.Point, src image.Image, sr image.Rectangle, op draw.Op, unchanged bool)

func (*Drawer) DestBounds

func (dw *Drawer) DestBounds() image.Rectangle

func (*Drawer) End added in v0.3.2

func (dw *Drawer) End()

End ends image drawing rendering process on render target. This is the thing that actually does the drawing for the web backup 2D image drawer.

func (*Drawer) Renderer added in v0.3.2

func (dw *Drawer) Renderer() any

func (*Drawer) Scale added in v0.3.2

func (dw *Drawer) Scale(dr image.Rectangle, src image.Image, sr image.Rectangle, rotateDeg float32, op draw.Op, unchanged bool)

func (*Drawer) Start added in v0.3.2

func (dw *Drawer) Start()

func (*Drawer) Transform added in v0.3.2

func (dw *Drawer) Transform(xform math32.Matrix3, src image.Image, sr image.Rectangle, op draw.Op, unchanged bool)

type Window

type Window struct {
	base.WindowSingle[*App]
}

Window is the implementation of system.Window for the web platform.

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

Directories

Path Synopsis
Package jsfs provides a Node.js style filesystem API in Go that can be used to allow os functions to work on wasm.
Package jsfs provides a Node.js style filesystem API in Go that can be used to allow os functions to work on wasm.

Jump to

Keyboard shortcuts

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