鞋子问题:剪贴板和滚动条 [英] Shoes problems: clipboard and scroll bar

查看:117
本文介绍了鞋子问题:剪贴板和滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码(至少)有两个问题:Copy按钮不会更新剪贴板,并且edit_box在应有的时候不显示垂直滚动条.

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

Paste按钮将剪贴板内容正确粘贴到edit_box中.如果进行更改,则单击Copyalert消息将显示正确的字符数.如果再次单击Paste,将粘贴原始剪贴板内容. Copy按钮永远不会正确更新剪贴板.

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.

此外,如果通过编辑或粘贴生成的行超出了edit_box的行数,则不会出现滚动条.

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

在这两个问题上的任何帮助将不胜感激.如果可以,我的环境是Windows XP.

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

更新答案:感谢@Pesto回答了剪贴板问题.事实证明,使用app.self.限定clipboardPasteCopy按钮中都可以正常工作.

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.

在深入研究滚动条问题之后,我想我理解了为什么edit_box不显示滚动条的原因.鞋子中的滚动条仅适用于插槽(stackflow),不适用于edit_box之类的单个元素. edit_box高度的指定方式始终使其适合包围的stack,因此stack永远不需要滚动条.这导致我遇到了一个不理想的解决方法,但是对于我的应用程序来说是可以接受的.只需将edit_box高度更改为大于所需的值(例如"10000px"),就会出现滚动条.不幸的是,无论是否需要它,都比没有滚动条要好.我确信,其他一些修补程序可以动态更改edit_box高度以完全适合内容,以便滚动条仅在需要时显示.

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.

推荐答案

首先,简单易行:将复制"按钮中的行更改为app.clipboard = @sql.text.

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

第二,就滚动条而言,这是已知问题在Windows XP上.我没有在github的错误报告中看到它,但是最新版本(r1229)仍然没有滚动条.

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.

这篇关于鞋子问题:剪贴板和滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆