apps-script TextArea:无法使用setCursorPos将文本滚动到视图中

时间:2012-07-30 15:41:42

标签: scroll textarea google-apps-script

我在气体TextArea中有一个长文本,我想将一行文本滚动到视图中。我尝试了几种解决方案(setCursorPos,setSelectionRange),但文本始终显示在顶部;即它永远不会向下滚动到我想要的位置......

我确实注意到该文档说:“这只有在TextArea附加到文档而不是隐藏时才会起作用。”这应该不适用于我的情况(我希望应用程序弹出特定位置......),但我尝试在应用程序显示之前和之后设置它。

这是代码。

....
var cursorPos=15;//just a test...
var fileString = "a very long text that I'm not putting in here....";
var mytextArea=myapp.createTextArea().setValue(fileString).setSize("100%","100%").setName("TextArea").setId("TextArea");
myapp.add(mytextArea.setCursorPos(cursorPos));
var doc=SpreadsheetApp.getActive();
doc.show(myapp);
myapp.getElementById("TextArea").setFocus().setCursorPos(cursorPos);

我必须做一些明显错误的事情。有什么建议?

2 个答案:

答案 0 :(得分:0)

问题在这里:http://code.google.com/p/google-apps-script-issues/issues/detail?id=1635 问题的回应是:“不幸的是,这是对基础GWT技术的限制”:(所以不能很快修复......:即setCursorPos(cursorPos)什么都不做......

答案 1 :(得分:0)

您是否尝试在滚动面板中包裹文本区域并设置滚动面板的位置?