FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I scroll with the cusror?

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon Mar 25, 2013 3:27 pm    Post subject: How do I scroll with the cusror? Reply with quote

I'm guessing to use scrollToIter. But how do I set the iter to be connected to the cursor?
Back to top
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Mon Mar 25, 2013 3:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon Mar 25, 2013 5:50 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Tue Mar 26, 2013 4:51 am    Post subject: Reply with quote

So how do I keep the cursor from going out of sight in a text area?
Back to top
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Tue Mar 26, 2013 4:01 pm    Post subject: Reply with quote

As far as i know following the cursor is the default behavior if the TextView is in a ScrolledWindow.
Back to top
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Tue Mar 26, 2013 4:43 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Wed Mar 27, 2013 3:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Wed Mar 27, 2013 4:40 pm    Post subject: Reply with quote

Thanks Mike. That did it. I'll have to find some more questions to ask, now.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group