GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Jul 31, 2014 11:27 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: getting the cursor position in a textview widget
PostPosted: Sat Dec 19, 2009 9:46 pm 
Offline
GTK+ Geek

Joined: Mon Jan 05, 2009 9:37 am
Posts: 68
Location: Austria
Dear All,

I have a scrollable textview widget in my application, and I would like to get the position of the cursor, if, say, Tab is hit. I can get the position in character units, but that is not what I want. I would like to get it in pixels, either relative to the main window, or in absolute units. Which function can I use to retrieve the position?
Thanks,
Zoltán


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 19, 2009 10:43 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello.

The function you're looking for is gtk_tree_view_get_iter_location(). This will give you a rectangle that roughly encapsulates the current character in text buffer coordinates. You can then convert those coordinates using gtk_text_view_buffer_to_window_coordinates() (window being widget window) to widget relative coordinates. These can then be used to obtain proper coordinates for example poping-up a completion menu.

Tadej


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 19, 2009 11:16 pm 
Offline
GTK+ Geek

Joined: Mon Jan 05, 2009 9:37 am
Posts: 68
Location: Austria
Dear Tadej,

Thanks for the prompt reply!
Quote:
The function you're looking for is gtk_tree_view_get_iter_location().

Sometimes it is a bit unintuitive where exactly one has to look for a particular function. I read the full textview documentation from A to Z, but there was nothing that I could use.

Quote:
These can then be used to obtain proper coordinates for example popping-up a completion menu.

Ha! You put your finger on it:) Precisely that is why I need it.
Thanks again,
Zoltán
[/quote]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group