Search code examples
rubyshoes

Shoes Clipboard Access from App


I am having problems getting the clipboard contents from within an app, using ruby shoes. I have tried the solution Shoes problems: clipboard and scroll bar, which does not work, as well as several other self-made solutions. According to http://shoesrb.com/manual/App.html, these attempts should work. My current attempt is:

def someFunction
    @theapp = Shoes.app(title: "AppName", width: 400) {
        @clip = edit_box width: 400, height: 400, text: app.clipboard do
            app.clipboard = @clip.text
        end
    }
end

As well as referencing app.clipboard, I have attempted Shoes.clipboard, Shoes.app.clipboard, self.clipboard, and @theapp.clipboard, all of which have failed. Some of them have even caused a blank window to appear without any elements in it. How can I fix this strange issue?


Solution

  • Try capturing the content of the edit_box in a block parameter:

    Shoes.app do
      edit_box do |clip|
        app.clipboard = clip.text
      end
    end
    

    Your question helped us to fix a bug in the upcoming release of Shoes 4. Thanks :)