Re: [gtk-list] Re: Selection behavior in entries (RFC)



I thought a yet anothor selection behavior.

 * Replace inactive selection if 2nd mouse button is pressed over the
   selection.
 * Insert selection text into clicked position if entry is the selection owner
   or the case not included in first case.

This is achieved with following patch. What do you think?



                                  -Takashi Matsuda
                                   matsu@arch.comp.kyutech.ac.jp


--- gtkentry.c.bak	Fri Nov 21 14:02:29 1997
+++ gtkentry.c	Fri Nov 21 14:03:36 1997
@@ -719,10 +719,22 @@
     {
       if (event->button == 2)
 	{
-	  if (entry->selection_start_pos == entry->selection_end_pos)
-	    entry->current_pos = gtk_entry_position (entry, event->x + entry->scroll_offset);
+	  gint current_pos;
+
+	  current_pos = gtk_entry_position (entry, event->x + entry->scroll_offset);
+	  if ((entry->selection_start_pos == entry->selection_end_pos) ||
+	      entry->have_selection )
+	    entry->current_pos = current_pos;
+	  else if ((entry->selection_start_pos >= current_pos) ||
+	           (entry->selection_end_pos <= current_pos))
+	    {
+	      entry->current_pos = current_pos;
+	      entry->selection_start_pos = 0;
+	      entry->selection_end_pos = 0;
+	    }
+	    
 	  gtk_selection_convert (widget, GDK_SELECTION_PRIMARY,
-				 GDK_TARGET_STRING, event->time);
+				 ctext_atom, event->time);
 	}
       else
 	{



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