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

编程入门 行业动态 更新时间:2024-10-22 02:53:22
本文介绍了鞋子问题:剪贴板和滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

下面的代码(至少)有两个问题: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中.如果进行更改,则单击Copy,alert消息将显示正确的字符数.如果再次单击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.限定clipboard在Paste和Copy按钮中都可以正常工作.

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不显示滚动条的原因.鞋子中的滚动条仅适用于插槽(stack和flow),不适用于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.

更多推荐

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

本文发布于:2023-11-03 15:18:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555431.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:剪贴板   鞋子   滚动条

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!