Shoes problems: clipboard and scroll bar

我的未来我决定 提交于 2019-12-11 00:52:33

问题


The code below has (at least) two problems: the Copy button doesn't update the clipboard, and the edit_box doesn't show a vertical scroll bar when it should.

Shoes.app (:title => "Test", :width => 1000, :height => 600) do
  background "#DFA"
  stack :margin => 30 do
    flow do
      button "Paste" do
        @sql.text = clipboard
      end
      button "Copy", :margin_left => 15 do
        clipboard = @sql.text
        alert(@sql.text.length.to_s + " characters copied to clipboard.")
      end
    end
    stack :margin_top => 10, :width => "100%", :height => 500, :scroll => true do
      @sql = edit_box :width => "100%", :height => "100%"
    end
  end
end

The Paste button correctly pastes the clipboard contents into the edit_box. If you make changes, then click Copy, the alert message displays the correct number of characters. If you then click Paste again, the original clipboard contents are pasted. The Copy button never correctly updates the clipboard.

Also, if you generate more lines than fit the edit_box, either by editing or pasting, no scroll bar ever appears.

Any help on these two issues will be much appreciated. My environment is Windows XP if that helps.

UPDATE WITH ANSWERS: Thanks to @Pesto for answering the clipboard question. It turns out that qualifying clipboard with either app. or self. works as expected in both the Paste and Copy buttons.

After digging deeper into the scrollbar issue, I think I understand why the edit_box doesn't show a scrollbar. The scrollbar in Shoes applies only to slots (stack and flow), and not to individual elements like edit_box. The edit_box height is specified in such a way as to always fit within the enclosing stack, so the stack never needs a scrollbar. This led me to a work-around that is not ideal, but is acceptable for my application. Simply change the edit_box height to a larger-than-necessary value such as "10000px" and the scrollbar appears. Unfortunately, it's there whether needed or not, but that's better than no scrollbar. I'm sure that some additional tinkering can dynamically change the edit_box height to exactly fit the contents, so that the scrollbar will appear only when needed.


回答1:


First of all, the easy one: change the line in the Copy button to app.clipboard = @sql.text.

Second, as far as the scrollbar goes, this is a known issue on Windows XP. I don't see it listed in the bug reports on github, but the latest version (r1229) still doesn't have a scrollbar.



来源:https://stackoverflow.com/questions/798947/shoes-problems-clipboard-and-scroll-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!