Documentation ¶
Overview ¶
Package dom wraps JS DOM functionality.
Index ¶
- Constants
- func CaretMove(pos int)
- func GetUrl() url.URL
- func Handle(event EventName, h Handler)
- func HandleRemove(event EventName, h Handler)
- func InsertText(str string)
- func SelectText(start, end int)
- type Base
- type Element
- func (x Element) Add(pos int, e ...Base)
- func (x Element) Append(e ...Base)
- func (x Element) Base() Element
- func (x Element) Blur()
- func (x Element) Class() string
- func (x Element) ClassSet(name string)
- func (x Element) Delete(i int)
- func (x Element) EditableSet(t bool)
- func (x Element) Focus()
- func (x Element) Handle(event EventName, h Handler)
- func (x Element) HandleRemove(event EventName, h Handler)
- func (x Element) Height() uint16
- func (x Element) HeightVisible() uint16
- func (x Element) Id() string
- func (x Element) IdSet(id string)
- func (x Element) Kind() ElementKind
- func (x Element) Len() int
- func (x Element) Next() Element
- func (x Element) Previous() Element
- func (x Element) Remove(e ...Base)
- func (x Element) RemoveSelf()
- func (x Element) Replace(newElem, oldElem Base)
- func (x Element) SpellcheckSet(val bool)
- func (x Element) Style(style ...css.Style)
- func (x Element) Sub(i int) Element
- func (x Element) SubKind(kind ElementKind) []Element
- func (x Element) Super() Element
- func (x Element) TabIndexSet(i int)
- func (x Element) Text() string
- func (x Element) TextSet(s string)
- func (x Element) Width() uint16
- func (x Element) WidthVisible() uint16
- type ElementKind
- type Event
- type EventName
- type Handler
- type KeyboardEvent
- type MouseEvent
- type Svg
- type WheelEvent
Constants ¶
const ( EventBlur EventName = "blur" EventChange = "change" EventClick = "click" EventClickRight = "contextmenu" EventFocusIn = "focusin" EventFocusOut = "focusout" EventInput = "input" EventKeyDown = "keydown" EventKeyUp = "keyup" EventMouseDown = "mousedown" EventMouseEnter = "mouseenter" EventMouseLeave = "mouseleave" EventMouseMove = "mousemove" EventMouseUp = "mouseup" EventMouseWheel = "mousewheel" )
Variables ¶
This section is empty.
Functions ¶
func CaretMove ¶
func CaretMove(pos int)
CaretMove moves caret position inside the current selection.
func HandleRemove ¶
func InsertText ¶
func InsertText(str string)
InsertText inserts the given string at the current cursor position.
func SelectText ¶
func SelectText(start, end int)
SelectText selects text inside the current active element.
Types ¶
type Element ¶
A Base represents a JS DOM element and forms the basis of this package. It wraps js.Value and gives access to all its funcionality.
func GetId ¶
GetId returns the element with the given ID in the document. Returns an error if the ID doesn't exist.
func GetKind ¶
func GetKind(kind ElementKind) []Element
GetKind returns all elements of the specified kind (tag).
func (Element) EditableSet ¶
func (Element) HandleRemove ¶
HandleRemove unsubscribes the given Handler from the specified event.
func (Element) HeightVisible ¶ added in v0.2.4
func (Element) Kind ¶
func (x Element) Kind() ElementKind
func (Element) Next ¶
Next returns the next element in the same node. Returns an empty Element if there is none.
func (Element) Previous ¶
Previous returns the previous element in the same node. Returns an empty Element if there is none.
func (Element) RemoveSelf ¶
func (x Element) RemoveSelf()
RemoveSelf removes the target Element from the dom
func (Element) SpellcheckSet ¶
func (Element) SubKind ¶
func (x Element) SubKind(kind ElementKind) []Element
func (Element) TabIndexSet ¶ added in v0.2.4
func (Element) Text ¶
Text returns the inner HTML text node value. Panics if x does not contain a text node.
func (Element) WidthVisible ¶ added in v0.2.4
type ElementKind ¶
type ElementKind string
type Event ¶
An Event wraps a JS event object
func (Event) CancelDefault ¶
func (x Event) CancelDefault()
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
A Handler wraps a JS event handler function.
func MakeHandler ¶
MakeHandler wraps a Go function to be used as a DOM event handler. fn must be non blocking, otherwise the application will deadlock. Notably, http requests block.
type KeyboardEvent ¶
type KeyboardEvent struct {
Event
}
func (KeyboardEvent) Ctrl ¶
func (x KeyboardEvent) Ctrl() bool
Ctrl returns true if the Ctrl key is being pressed.
func (KeyboardEvent) Key ¶
func (x KeyboardEvent) Key() string
type MouseEvent ¶
type MouseEvent struct {
Event
}
func (MouseEvent) Button ¶ added in v0.2.4
func (x MouseEvent) Button() byte
func (MouseEvent) XAbs ¶ added in v0.2.4
func (x MouseEvent) XAbs() uint16
func (MouseEvent) XRel ¶ added in v0.2.4
func (x MouseEvent) XRel() uint16
func (MouseEvent) YAbs ¶ added in v0.2.4
func (x MouseEvent) YAbs() uint16
func (MouseEvent) YRel ¶ added in v0.2.4
func (x MouseEvent) YRel() uint16
type WheelEvent ¶ added in v0.2.4
type WheelEvent struct {
Event
}
func (WheelEvent) Y ¶ added in v0.2.4
func (x WheelEvent) Y() int8