ole

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ole is the OLE drag and drop of the Windows backend (SPEC §25.10): the COM objects that Go makes for it (IDropTarget, IDropSource, IDataObject and IEnumFORMATETC, SPEC §25.2), the reader of a data object that another program made, and the plain-Go models they stand on, which are tested on any host: the effects and the keys that choose among them, the formats and their names, the set of data that a drag offers, the enumerator of formats, and the decisions of the drag source.

The files that call Windows are named *_windows.go. The policy (what a drop means to the framework, what a drag offers) is package windows (dnd.go): this package knows bytes and formats, not widgets.

Flutter: no counterpart (Flutter has no drag and drop between applications)

Index

Constants

View Source
const (
	// MIMEPlain is the type of the text formats.
	//
	// Flutter: no counterpart
	MIMEPlain = "text/plain"
	// MIMEPlainUTF8 is the type of the UTF-16 text format, as the other backends name text.
	//
	// Flutter: no counterpart
	MIMEPlainUTF8 = "text/plain;charset=utf-8"
	// MIMEURIList is the type of the files and of the URL formats.
	//
	// Flutter: no counterpart
	MIMEURIList = "text/uri-list"
	// MIMEPNG is the type of the registered format "PNG".
	//
	// Flutter: no counterpart
	MIMEPNG = "image/png"
	// MIMEHTML is the type of the registered format "HTML Format".
	//
	// Flutter: no counterpart
	MIMEHTML = "text/html"
	// LocalMarkerPrefix starts the name of the format that a drag started by an app offers besides its
	// data: "application/x-glutter-drag-<pid>-<id>" (SPEC §8.11).
	//
	// Flutter: no counterpart
	LocalMarkerPrefix = "application/x-glutter-drag-"
)

The types (MIME types, as on the other platforms) that the formats of a drag are reported as.

Variables

This section is empty.

Functions

func ActionsOf

func ActionsOf(effect uint32) ui.DropActions

ActionsOf turns the effects of OLE (DROPEFFECT_*) into the actions of the framework. DROPEFFECT_SCROLL and the bits that are not effects are dropped.

Flutter: no counterpart

func ButtonKeys

func ButtonKeys(buttons int) uint32

ButtonKeys turns the pointer buttons of the framework (the bits of ui.PointerData.Buttons: primary 1, secondary 2, middle 4) into the MK_* bits that a drop target's key state has.

Flutter: no counterpart

func EffectFor

func EffectFor(accepted ui.DropActions, allowed uint32) uint32

EffectFor is the effect to return to OLE for the action the framework accepted, among the effects the source allows: the accepted action when the source allows it, else the first of copy, move and link that both the framework accepted and the source allows, else DROPEFFECT_NONE.

Flutter: no counterpart

func EffectOf

func EffectOf(a ui.DropActions) uint32

EffectOf turns the actions of the framework into the effects of OLE; no action is DROPEFFECT_NONE.

Flutter: no counterpart

func FormatEtcOf

func FormatEtcOf(format uint32) win32.FormatEtc

FormatEtcOf is the FORMATETC that describes the format on global memory.

Flutter: no counterpart

func IsMarker

func IsMarker(name string) bool

IsMarker says whether the name is the marker of any drag of this app (of any process).

Flutter: no counterpart

func LocalIDOf

func LocalIDOf(name string, pid int) uint64

LocalIDOf is the ID of the drag request of the process pid that a format name marks, 0 when the name is not a marker of this process.

Flutter: no counterpart

func LocalMarker

func LocalMarker(pid int, id uint64) string

LocalMarker is the name of the format that marks a drag of this process: the process ID keeps the drags of another instance of the app from being taken for ours.

Flutter: no counterpart

func MIMEOf

func MIMEOf(format uint32, name string) string

MIMEOf is the type that a format of a drag is reported as. name is the name of a registered format ("" for a standard one). The files are text/uri-list, the text formats text/plain, the two URL formats text/uri-list, "PNG" image/png and "HTML Format" text/html; another registered format is reported by its name, and a standard format that is not known, by "" (it is left out).

Flutter: no counterpart

func OfferedActions

func OfferedActions(keyState uint32, allowed ui.DropActions) ui.DropActions

OfferedActions are the actions the framework may choose from for a drag over a target: the actions the source allows, narrowed to the one that the keys ask for when the source allows it. The convention of Windows is Ctrl for copy, Shift for move, and Ctrl+Shift or Alt for link; with no key the source's whole set is offered, and the framework chooses (copy first).

Flutter: no counterpart

func PID

func PID() int

PID is the process ID the markers carry.

Flutter: no counterpart

func StringData

func StringData(s string, wide bool) []byte

StringData is the data of a text or URL format: the string with a terminating NUL, UTF-16 when wide, else ANSI (a character above U+00FF is "?").

Flutter: no counterpart

func StringFromData

func StringFromData(b []byte, wide bool) string

StringFromData reads the string of the data of a URL format: UTF-16 when wide, else one byte per character (Latin-1: the ANSI code page is not known here). The string ends at the first NUL.

Flutter: no counterpart

Types

type DataSet

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

DataSet is the data of a drag that the app starts, as formats in the order they are offered. Every format is on global memory (TYMED_HGLOBAL), for the content aspect, as the formats of the clipboard are. It is not changed once the drag has begun.

Flutter: no counterpart

func NewDataSet

func NewDataSet(items ...Item) *DataSet

NewDataSet makes a set of the items; a format given twice keeps its first place and its last data.

Flutter: no counterpart

func (*DataSet) Add

func (s *DataSet) Add(format uint32, data []byte)

Add puts the data of the format in the set: a format that is there already is replaced in place.

Flutter: no counterpart

func (*DataSet) Formats

func (s *DataSet) Formats() []uint32

Formats lists the formats in the order they were added.

Flutter: no counterpart

func (*DataSet) Get

func (s *DataSet) Get(format uint32) ([]byte, bool)

Get returns the data of the format.

Flutter: no counterpart

func (*DataSet) Query

func (s *DataSet) Query(fe win32.FormatEtc) win32.HRESULT

Query is IDataObject::QueryGetData for the format: S_OK when the set has it on global memory in the content aspect for the whole data, else the code the method gives (DV_E_DVASPECT, DV_E_LINDEX, DV_E_TYMED, DV_E_FORMATETC, in the order the checks are made).

Flutter: no counterpart

type DataSource

type DataSource interface {
	// Formats lists the formats that can be read as global memory, in the source's order.
	Formats() ([]uint32, error)
	// Read returns a copy of the data of the format.
	Read(format uint32) ([]byte, error)
	// Close releases the data object.
	Close()
}

DataSource is the data of a drag as a drop target sees it: the formats on offer and the bytes of each. Reader implements it over the IDataObject of the source; the tests use a fake. Close gives the reference to the data object back; the target closes a source once.

Flutter: no counterpart

type Decision

type Decision int

Decision is what a drag source answers to IDropSource::QueryContinueDrag.

Flutter: no counterpart

const (
	// Continue goes on with the drag (S_OK).
	//
	// Flutter: no counterpart
	Continue Decision = iota
	// Drop ends the drag with a drop on the target under the pointer (DRAGDROP_S_DROP).
	//
	// Flutter: no counterpart
	Drop
	// Cancel ends the drag without a drop (DRAGDROP_S_CANCEL).
	//
	// Flutter: no counterpart
	Cancel
)

The answers of QueryContinueDrag.

func (Decision) HRESULT

func (d Decision) HRESULT() win32.HRESULT

HRESULT is the value the method returns for the decision.

Flutter: no counterpart

type FormatEnum

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

FormatEnum is the state of an IEnumFORMATETC over the formats of a data set: the position, with the four operations of the interface. The COM object (dataobject_windows.go) only moves the formats to and from the memory that the caller gave.

Flutter: no counterpart

func NewFormatEnum

func NewFormatEnum(formats []uint32) *FormatEnum

NewFormatEnum enumerates a copy of the formats, from the first.

Flutter: no counterpart

func (*FormatEnum) Clone

func (e *FormatEnum) Clone() *FormatEnum

Clone is an enumerator at the same position, which moves on its own.

Flutter: no counterpart

func (*FormatEnum) Next

func (e *FormatEnum) Next(n int) []uint32

Next returns up to n formats from the position and moves past them. Fewer than n means the end was reached (the method returns S_FALSE).

Flutter: no counterpart

func (*FormatEnum) Reset

func (e *FormatEnum) Reset()

Reset goes back to the first format.

Flutter: no counterpart

func (*FormatEnum) Skip

func (e *FormatEnum) Skip(n int) bool

Skip moves past n formats and reports whether there were that many (S_OK); the position is the end otherwise (S_FALSE).

Flutter: no counterpart

type Item

type Item struct {
	Format uint32
	Data   []byte
}

Item is one format of a data set: the number of the clipboard format and its bytes.

Flutter: no counterpart

type SourceMachine

type SourceMachine struct {
	// Buttons are the MK_* bits of the pointer buttons that started the drag: the drag goes on while
	// one of them is down.
	Buttons uint32
	// Cancelled is set by the platform to end the drag at the next question.
	Cancelled bool
	// LastEffect is the effect that GiveFeedback saw last: what a drop would do now.
	LastEffect uint32
}

SourceMachine is the drag source's rule for ending a drag (SPEC §25.10): the drop happens when the button that started the drag is released, Escape cancels, and the platform can cancel for its own reasons (the window of the drag closes, the app ends). It is the same rule as Explorer's. It belongs to the UI thread.

Flutter: no counterpart

func (*SourceMachine) Feedback

func (m *SourceMachine) Feedback(effect uint32) win32.HRESULT

Feedback records the effect GiveFeedback was told about and says to leave the cursors of Windows.

Flutter: no counterpart

func (*SourceMachine) Query

func (m *SourceMachine) Query(escape bool, keyState uint32) Decision

Query answers QueryContinueDrag: Cancel when Escape was pressed or the platform cancelled, Drop when the buttons that started the drag are all up, else Continue. A machine with no buttons drops at once, as OLE would for a drag that starts with the button already up.

Flutter: no counterpart

type Target

type Target struct {
	// H handles the drag.
	H TargetHandler
	// contains filtered or unexported fields
}

Target is the state machine of an IDropTarget: it keeps the data object between DragEnter and DragLeave or Drop, and makes sure it is released once, in the order OLE calls the methods. A DragOver or DragLeave with no DragEnter before it does nothing and answers no effect.

Flutter: no counterpart

func (*Target) Drop

func (t *Target) Drop(data DataSource, keyState uint32, pt win32.Point, effect uint32) uint32

Drop is IDropTarget::Drop: data is a new reference that is released when the call returns, as is the one that DragEnter kept.

Flutter: no counterpart

func (*Target) Enter

func (t *Target) Enter(data DataSource, keyState uint32, pt win32.Point, effect uint32) uint32

Enter is IDropTarget::DragEnter: data is a new reference that the target keeps until the drag ends.

Flutter: no counterpart

func (*Target) Leave

func (t *Target) Leave()

Leave is IDropTarget::DragLeave.

Flutter: no counterpart

func (*Target) Over

func (t *Target) Over(keyState uint32, pt win32.Point, effect uint32) uint32

Over is IDropTarget::DragOver.

Flutter: no counterpart

type TargetHandler

type TargetHandler interface {
	// DragEnter is a drag that came over the window. data is valid until DragLeave or Drop returns.
	DragEnter(data DataSource, keyState uint32, pt win32.Point, effect uint32) uint32
	// DragOver is the drag moving over the window, or the keys changing.
	DragOver(keyState uint32, pt win32.Point, effect uint32) uint32
	// DragLeave is the drag leaving the window without a drop.
	DragLeave()
	// Drop is the drop on the window; the target reads the data now.
	Drop(data DataSource, keyState uint32, pt win32.Point, effect uint32) uint32
}

TargetHandler is what a window does with the drag over it (SPEC §25.10). The effect arguments and results are DROPEFFECT_* sets: the argument is what the source allows, the result is the effect the target chooses (DROPEFFECT_NONE for none). The point is in screen coordinates. All of it runs on the UI thread.

Flutter: no counterpart

Jump to

Keyboard shortcuts

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