Re: selecting text area

On Tue, 1 Aug 2000 wrote:


> hello all,
> just needed a signal to be emitted whenever region of text is selected
> by keyboard or mouse
> pressing (in a object of type GTK_TEXT), couldn't find one such type.
> just wanted to know if or how that is done.

 Here is how I would try to do this (I didn't try this :)  :
 connect to key_press_event, key_release_event, button_press_event,
"motion-notify-event" (I don't know what is it - probably it issued when mouse
is moving) to the area on which selections you want to monitor. After each
invokation of the signal handler, check the values of
GTK_EDITABLE(textarea)->selection_start_pos and 
GTK_EDITABLE(textarea)->selection_end_pos. If they are changed (comparing
with the values stored on previous call), than visual selection is changed.
 Also note, that gtk itself uses the following code for getting selection:
selection_start_pos = MIN (editable->selection_start_pos,
selection_end_pos = MAX(editable->selection_start_pos,

 Probably you should also use the same for detecting real start and end
positions of selection.

> rinu

 Best regards,

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