NSScrollView指定滚动条移动的位置

来源:互联网 发布:java 日历选择控件 编辑:程序博客网 时间:2024/05/21 14:47

 文章来源:http://www.cocoachina.com/bbs/read.php?tid=50798&keyword=textview

 

m_textView :NSTextView

m_view:包含NSTextView的视图

 

float ScrollLocation = 0.0;     float MaxScroll = 0.0;[[m_textview enclosingScrollView] setLineScroll:0.0f];[[m_textview enclosingScrollView] setPageScroll:0.0f];  ScrollLocation = [[[m_textview enclosingScrollView] contentView] bounds].origin.y;    MaxScroll = [[[m_textview enclosingScrollView] documentView] bounds].size.height - [[m_textview enclosingScrollView] documentVisibleRect].size.height;         ScrollLocation += 10;          if(ScrollLocation < 0)      {           ScrollLocation = 0;      }          else if(ScrollLocation >MaxScroll)        {          ScrollLocation = MaxScroll;      }  [[m_view contentView] scrollToPoint:NSMakePoint(0, ScrollLocation)]; 

原创粉丝点击