web

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 19 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) 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) 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) 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 {
	system.DrawerBase
}

Drawer is a TEMPORARY, low-performance implementation of system.Drawer. It will be replaced with a full WebGPU based drawer at some point. TODO: replace Drawer with WebGPU

func (*Drawer) DestBounds

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

DestBounds returns the bounds of the render destination

func (*Drawer) EndDraw

func (dw *Drawer) EndDraw()

EndDraw ends image drawing rendering process on render target. This is the thing that actually does the drawing on web.

type Window

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

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

func (*Window) Handle

func (w *Window) Handle() any

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