Search code examples
reflectionserviceclipboardwebosenyo

Accessing the WebOS clipboard From an Enyo Application


When developing a WebOS application with Enyo, is it possible to access the clipboard contents? That is, if I copy a bit of text to the clipboard on a Touchpad or Pre device , can I programmatically grab that piece of text, or programmatically replace it?

From what I've read in the SDK documents, I assume I'd need a Service to do this. Is this correct?

If so, which service? Are there a list of services available, and/or is there a way to reflect into the framework to see which services are available?

(New to WebOS development, so error on the side of speaking loudly and slowly)


Solution

  • I think you are looking for the getClipboard method on the enyo.dom. However, when I try:

    enyo.dom.getClipboard(enyo.bind(this, "gotClipboard"));
    
    
    gotClipboard: function() {
        this.log(JSON.stringify(arguments));
    }
    

    I just get {"0",""}, even though I have text in the clipboard. It makes me wonder if this isn't fully baked yet. One argument will be the text in the clipboard when it works.

    If I try the companion enyo.dom.setClipboard, I get a NOT_FOUND_ERR: DOM Exception 8.

    Found both of these functions in here: https://developer.palm.com/content/api/reference/enyo/enyo-api-reference.html