Example #1
0
        public bool OnCompletedLayout(NSLayoutManager layout, bool atEnd)
        {
            bool finished = false;

            if (atEnd || (m_origin == NSPoint.Zero && layout.firstUnlaidCharacterIndex() > m_selected.location + 100))
            {
                if (m_length == -1 || m_length == m_controller.Text.Length)	// only restore the view if it has not changed since we last had it open
                {
                    if (m_origin != NSPoint.Zero)
                    {
                        var clip = m_controller.ScrollView.contentView().To<NSClipView>();
                        clip.scrollToPoint(m_origin);
                        m_controller.ScrollView.reflectScrolledClipView(clip);

                        if (m_selected != NSRange.Empty)
                            m_controller.TextView.setSelectedRange(m_selected);
                    }
                    else if (m_selected != NSRange.Empty && m_selected.location + m_selected.length <= m_controller.TextView.textStorage().string_().length())
                    {
                        m_controller.TextView.setSelectedRange(m_selected);
                        m_controller.TextView.scrollRangeToVisible(m_visible);

                        m_controller.TextView.showFindIndicatorForRange(m_deferred);
                    }
                }

                finished = true;
            }

            return finished;
        }