Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate clipboard modification from Window interface #106

Closed
azul3d-bot opened this issue Mar 6, 2016 · 1 comment
Closed

Separate clipboard modification from Window interface #106

azul3d-bot opened this issue Mar 6, 2016 · 1 comment

Comments

@azul3d-bot
Copy link

Issue by slimsag
Wednesday Nov 26, 2014 at 00:35 GMT
Originally opened as azul3d-legacy/gfx#51


Today to implement window.Window you must provide a string-based clipboard implementation as well:

// Window represents a single window that graphics can be rendered to. The
 // window is safe for use concurrently from multiple goroutines.
 type Window interface {
        ...
        // SetClipboard sets the clipboard string.
        SetClipboard(clipboard string)

        // Clipboard returns the clipboard string.
        Clipboard() string
        ...
}

This is unfortunate because one might be able to implement a Window in places where implementing a clipboard is not doable or easy. We could separate clipboard features into a separate interface, however:

type Clipboard interface {
    // SetClipboard sets the clipboard string.
    SetClipboard(clipboard string)

    // Clipboard returns the clipboard string.
    Clipboard() string
}

Then to test if a window.Window supports modifying the clipboard, you can simply:

cb, ok := win.(window.Clipboard)
if ok {
        // We have clipboard access.
        cb.SetClipboard("Hello World!")
}

This is also a good way that we could provide access to further clipboard data types (for example window.ClipboardImage, for image data perhaps).

@slimsag
Copy link
Member

slimsag commented Mar 6, 2016

Fixed/merged as part of #1

@slimsag slimsag closed this as completed Mar 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants