View previous topic :: View next topic |
Author |
Message |
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Mon Mar 25, 2013 3:27 pm Post subject: How do I scroll with the cusror? |
|
|
I'm guessing to use scrollToIter. But how do I set the iter to be connected to the cursor? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Mon Mar 25, 2013 3:54 pm Post subject: |
|
|
Depending on what you are trying to do either:
getIterAtLocation or getIterAtPosition
And you can get an iter fron the text buffer:
Code: | TextBuffer buf = textView.getBuffer();
TextIter iter = new TextIter();
buf.getEndIter(iter);
//Or one of the other getIter functions from TextBuffer. |
|
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Mon Mar 25, 2013 5:50 pm Post subject: |
|
|
Yeah, I had looked at TextBuffer, but couldn't work it out. I use it for my text widgets.
I've tried the code you gave me, but no different. When I'm typing in my program in a text box, my cursor goes out of sight because the display hasn't changed for the cursor position. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Tue Mar 26, 2013 4:51 am Post subject: |
|
|
So how do I keep the cursor from going out of sight in a text area? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Tue Mar 26, 2013 4:01 pm Post subject: |
|
|
As far as i know following the cursor is the default behavior if the TextView is in a ScrolledWindow. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Tue Mar 26, 2013 4:43 pm Post subject: |
|
|
Code: | _textTagTable = new TextTagTable();
_textBuffer = new TextBuffer(_textTagTable);
_textView = new TextView(_textBuffer);
_textView.setWrapMode(GtkWrapMode.WORD);
_textView.setRightMargin(20); // spacing on the right works
_textView.setJustification(Justification.JUSTIFY_FILL);
//#ScrollWindow
_scWinMain = new ScrolledWindow(_textView);
_scWinMain.setMinContentWidth(400);
_scWinMain.setMinContentHeight(600);
_grid.attach(_scWinMain, 1,0,1,200); |
I think I do have my TextView object in a ScrolledWindow. I couldn't see any thing in the ScrollWindow class that had about my cursor problem. What else can I try? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Wed Mar 27, 2013 3:54 pm Post subject: |
|
|
There is a bug in the constructor for ScrolledWindow, for now you should be able to use:
Code: | _textTagTable = new TextTagTable();
_textBuffer = new TextBuffer(_textTagTable);
_textView = new TextView(_textBuffer);
_textView.setWrapMode(GtkWrapMode.WORD);
_textView.setRightMargin(20); // spacing on the right works
_textView.setJustification(Justification.JUSTIFY_FILL);
//#ScrollWindow
_scWinMain = new ScrolledWindow();
_scWinMain.add(_textView);
_scWinMain.setMinContentWidth(400);
_scWinMain.setMinContentHeight(600);
_grid.attach(_scWinMain, 1,0,1,200); |
|
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Wed Mar 27, 2013 4:40 pm Post subject: |
|
|
Thanks Mike. That did it. I'll have to find some more questions to ask, now. |
|
Back to top |
|
|
|