鞋子问题:剪贴板和滚动条

发布于 2024-07-17 10:44:46 字数 1636 浏览 8 评论 0原文

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

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 中。 如果您进行更改,然后单击复制警报消息将显示正确的字符数。 如果您再次单击粘贴,则会粘贴原始剪贴板内容。 Copy 按钮永远不会正确更新剪贴板。

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

任何有关这两个问题的帮助将不胜感激。 如果有帮助的话,我的环境是Windows XP。

更新答案:感谢@Pesto 回答剪贴板问题。 事实证明,使用 app.self. 限定 clipboardPastePaste 中都可以按预期工作。代码>复制按钮。

在深入研究滚动条问题后,我想我明白为什么 edit_box 不显示滚动条。 Shoes 中的滚动条仅适用于插槽(stackflow),而不适用于 edit_box 等单个元素。 edit_box 高度的指定方式始终适合封闭的 stack,因此 stack 永远不需要滚动条。 这导致我找到了一种并不理想的解决方法,但对于我的应用程序来说是可以接受的。 只需将 edit_box 高度更改为大于必要的值,例如 "10000px" 就会出现滚动条。 不幸的是,无论需要与否,它都在那里,但这比没有滚动条好。 我确信一些额外的修改可以动态更改 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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弃爱 2024-07-24 10:44:46

首先,最简单的一个:将“复制”按钮中的行更改为 app.clipboard = @sql.text

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文