Dear Allan Odgaard, dear list!
I'm coming here with perhaps a strange request: I'm trying to sidestep one "feature" of NSTextView and the only application which seems to implement similar behavior is TextMate so I was hoping you would be so kind to share the trick.
The thing is, when a window with NSTextView contains lots of text and the users scrolls to, say, 1/4 of text's height, places the text cursor somewhere, say, at the top of the window and then resizes the window, the textview does scroll so that the cursor appears the middle of the textview. In other words, by default, the window resize triggers NSTextView scroll which puts the cursor in the middle of the view. Which is what I'm trying to avoid, i.e. I want the cursor to stay where it was (if possible due to reflow).
I tried to ask at cocoadev [1] and StackOverflow [2] but got no answer so far. I tried Dux and Fragaria editors but they seem to auto-scroll as well. The only editor which I can resize the window of and which keeps the cursor at the same position is TextMate. I tried to search through its source code but I could not find the piece of code responsible for it.
Please, could you, or someone else, help me out with this? What did you do to avoid the default behavior?
Thanks a lot in advance!
Regards,
Ecir Hana
[1] http://lists.apple.com/archives/cocoa-dev/2014/Dec/msg00210.html [2] http://stackoverflow.com/questions/27651948/nstextview-auto-scroll
On 3 Jan 2015, at 21:48, ecir hana wrote:
[…] by default, the window resize triggers NSTextView scroll which puts the cursor in the middle of the view. Which is what I'm trying to avoid, i.e. I want the cursor to stay where it was (if possible due to reflow).
TextMate is not based on NSTextView, so the behavior you see in TextMate is not an indication of what NSTextView can or cannot do.
If I understand your issue correct, then I think by default NSScrollView/NSClipView will adhere to the resizing mask as to how the document view should behave when the containing clip view is being resized, but NSTextView could have special code being triggered on resize, though it probably wouldn’t, unless it actually scrolls the caret into the visible area.
Thanks a lot for the answer!
I see, I'll try to look into it further...
Have a nice day!
On Mon, Jan 5, 2015 at 5:44 PM, Allan Odgaard mailinglist@textmate.org wrote:
On 3 Jan 2015, at 21:48, ecir hana wrote:
[…] by default, the window resize triggers NSTextView scroll
which puts the cursor in the middle of the view. Which is what I'm trying to avoid, i.e. I want the cursor to stay where it was (if possible due to reflow).
TextMate is not based on NSTextView, so the behavior you see in TextMate is not an indication of what NSTextView can or cannot do.
If I understand your issue correct, then I think by default NSScrollView/NSClipView will adhere to the resizing mask as to how the document view should behave when the containing clip view is being resized, but NSTextView could have special code being triggered on resize, though it probably wouldn’t, unless it actually scrolls the caret into the visible area.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate