Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support for beginning/end of document in Textview

  • Loading branch information...
commit 57ad69fa51c6ea701440ea285962f22c8395859e 1 parent ca3845c
@michaelvillar authored
Showing with 40 additions and 0 deletions.
  1. +40 −0 lib/UIKit/TUITextRenderer+KeyBindings.m
View
40 lib/UIKit/TUITextRenderer+KeyBindings.m
@@ -253,6 +253,46 @@ - (void)moveToEndOfLine:(id)sender
[self _scrollToIndex:MAX(_selectionStart, _selectionEnd)];
}
+- (void)moveToBeginningOfParagraph:(id)sender
+{
+ [self moveToBeginningOfLine:sender];
+}
+
+- (void)moveToEndOfParagraph:(id)sender
+{
+ [self moveToEndOfLine:sender];
+}
+
+- (void)moveToBeginningOfParagraphAndModifySelection:(id)sender
+{
+ [self moveToBeginningOfLineAndModifySelection:sender];
+}
+
+- (void)moveToEndOfParagraphAndModifySelection:(id)sender
+{
+ [self moveToEndOfLineAndModifySelection:sender];
+}
+
+- (void)moveToBeginningOfDocument:(id)sender
+{
+ [self moveToBeginningOfLine:sender];
+}
+
+- (void)moveToEndOfDocument:(id)sender
+{
+ [self moveToEndOfLine:sender];
+}
+
+- (void)moveToBeginningOfDocumentAndModifySelection:(id)sender
+{
+ [self moveToBeginningOfLineAndModifySelection:sender];
+}
+
+- (void)moveToEndOfDocumentAndModifySelection:(id)sender
+{
+ [self moveToEndOfLineAndModifySelection:sender];
+}
+
- (void)insertNewline:(id)sender
{
[[self _textEditor] insertText:@"\n"];

12 comments on commit 57ad69f

@avaidyam

I'm sure I've asked this before, but a few of us TwUI users wanted to try allow for scrolling in the text views.... your method allows that if the container is a scroll view, so would it be possible to convert the entire TUITextView over to a TUIScrollView subclass?

@mrjjwright

Great work on all this.

@avaidyam

mrjjwright, do you know exactly what i'd need to do to get the TUITextView to become a proper, functioning subclass of TUIScrollView?

@michaelvillar

galaxas0 I succeeded to embed a TUITextView in a TUIScrollView without subclassing it. What's the problem?
I also improved auto scrolling when navigate with the keyboard, see this commit : ca3845c

@avaidyam

Oh, sorry, I meant something like this ( the ':' denotes subclass, much like ObjC):

Right now:
TUITextField : TUITextView : TUIControl : TUIView

Whereas, I want to modify it so:
TUITextField : TUIControl : TUIView

and:
TUITextView : TUIScrollView : TUIView

which is how I believe AppKit and UIKit do it.

@michaelvillar

Yes I understood. But I don't see the goal? :)

@avaidyam

Because the way it's set up now, we'd need to have the text view wrapped in ANOTHER scroll view... isn't this just a BIT much? :\ Just me and my OCD self, but I think I'll start looking for ways to ease the subclassing...

@mrjjwright

What are the steps here for embedding this in a TUIScrollView. I assume they are add the TUITextView as a subview of a TUIScrollView and set the contentSize of the scrollview based upon a measured string of the textview contents? @michaelvillar do you have a gist that would show how this is done?

I tried it this morning and my scrollview bounces but does not scroll through the text.

@avaidyam

Oh, it should be set as the content view, not subview. Once that's done, contentSize should automatically be modified by the changes done in this commit/the previous commit.

I've also been looking the text view becoming a scroll view subclass, and I think it's possible... I'll begin writing up a prototype for that.

@mrjjwright

Thanks for the response but TUIScrollView has a contentView? Sorry what do you mean?

@avaidyam

Oh, correction, I was looking at the wrong thing- yes, set it as subview, but the text view will take care of the rest.

Please sign in to comment.
Something went wrong with that request. Please try again.