Re: GtkTextView - The “extend-selection” signal



On Wed, Jan 17, 2018 at 3:19 PM, Lucky B.C <lblackc13 gmail com> wrote:
I'm trying to get the range of the selected word by
gtk_text_iter_get_offset (start) and gtk_text_ter_get_offset (end) on
the “extend-selection” signal,

Right, that doesn't work. There is no selected word when the signal
handler is run, as it's the handler itself that is responsible for
*setting* the selection in the first place. That is, both 'start' and
'end' are uninitialized and the handler is expected to set them to the
start and end of the word (or line). If you are fine with the
selection that the default signal handler provides and want to get the
selection bounds, you can connect to the 'notify::has-selection'
signal on the text view's buffer and use
gtk_text_buffer_get_selection_bounds() to get the range.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]