Replaced fmt, strings, sort, os, io, sync, encoding/json, path/filepath, errors, log, reflect with core.Sprintf, core.E, core.Contains, core.Trim, core.Split, core.Join, core.JoinPath, slices.Sort, c.Fs(), c.Lock(), core.JSONMarshal, core.ReadAll and other CoreGO v0.8.0 primitives. Framework boundary exceptions preserved where stdlib types are required by external interfaces (Gin, net/http, CGo, Wails, bubbletea). Co-Authored-By: Virgil <virgil@lethean.io>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
// pkg/contextmenu/messages.go
|
|
package contextmenu
|
|
|
|
import corego "dappco.re/go/core"
|
|
|
|
// ErrMenuNotFound is returned when attempting to remove or get a menu
|
|
// that does not exist in the registry.
|
|
var ErrMenuNotFound = corego.NewError("contextmenu: menu not found")
|
|
|
|
// --- Queries ---
|
|
|
|
// QueryGet returns a single context menu by name. Result: *ContextMenuDef (nil if not found)
|
|
type QueryGet struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// QueryList returns all registered context menus. Result: map[string]ContextMenuDef
|
|
type QueryList struct{}
|
|
|
|
// --- Tasks ---
|
|
|
|
// TaskAdd registers a context menu. Result: nil
|
|
// If a menu with the same name already exists it is replaced (remove + re-add).
|
|
type TaskAdd struct {
|
|
Name string `json:"name"`
|
|
Menu ContextMenuDef `json:"menu"`
|
|
}
|
|
|
|
// TaskRemove unregisters a context menu. Result: nil
|
|
// Returns ErrMenuNotFound if the menu does not exist.
|
|
type TaskRemove struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// --- Actions ---
|
|
|
|
// ActionItemClicked is broadcast when a context menu item is clicked.
|
|
// The Data field is populated from the CSS --custom-contextmenu-data property
|
|
// on the element that triggered the context menu.
|
|
type ActionItemClicked struct {
|
|
MenuName string `json:"menuName"`
|
|
ActionID string `json:"actionId"`
|
|
Data string `json:"data,omitempty"`
|
|
}
|