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.