After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 50940 - GtkEntry selection improvement [patch]
GtkEntry selection improvement [patch]
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
1.3.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
: 626696 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2001-02-16 10:14 UTC by Jay Cox
Modified: 2017-08-19 15:02 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jay Cox 2001-02-16 10:14:06 UTC
It should be possible to click and drag upwords to select the begining
portion of a gtkentry and also to click and drag downwards to select the
end portion of the entry.  This behaviour is standard on macOS.

If this version seems a bit too touchy when not trying to invoke this
feature, it would be trivial to add an angle of motion check which would
make it much less prone to accidental use.

-------------------------------------------------

diff -u -r1.106 gtkentry.c
--- gtk/gtkentry.c	2001/02/13 05:44:47	1.106
+++ gtk/gtkentry.c	2001/02/16 10:05:42
@@ -1145,8 +1145,20 @@
     }
   else
     {
+      int width, height;
       tmp_pos = gtk_entry_find_position (entry, event->x +
entry->scroll_offset);
+      gdk_window_get_size (entry->text_area, &width, &height);
 
+      if ((event->y - entry->drag_start_y) <= -height)
+      { /* user has dragged up so select to begining of line */
+	/* possibly pango problems? */
+	tmp_pos = 0;
+      }
+      if ((event->y - entry->drag_start_y) >= height)
+      { /* user has dragged down so select to end of line   */
+	/* possibly pango problems? */
+	tmp_pos = entry->text_length;
+      }
       if (tmp_pos != entry->current_pos)
 	{
 	  entry->current_pos = tmp_pos;
Comment 1 Owen Taylor 2001-07-19 17:56:42 UTC
Applying patch to do this. Instead of using relative motion,
I decided to go with absolute motion, so it makes a bit more
sense when it triggers. 

   else
     {
-      tmp_pos = gtk_entry_find_position (entry, event->x +
entry->scroll_offset);
+      gint height;
+      gdk_window_get_size (entry->text_area, NULL, &height);
+
+      if (event->y < 0)
+       tmp_pos = 0;
+      else if (event->y >= height)
+       tmp_pos = entry->text_length;
+      else
+       tmp_pos = gtk_entry_find_position (entry, event->x +
entry->scroll_offset);
+      
       gtk_entry_set_positions (entry, tmp_pos, -1);
     }
       
No pango considerations here - up should always mean go 
to the logical beginning of the line down to the logical
end of the line.
Comment 2 Daniel Boles 2017-08-19 15:00:17 UTC
*** Bug 626696 has been marked as a duplicate of this bug. ***
Comment 3 Daniel Boles 2017-08-19 15:02:48 UTC
for ref, this was pushed as commit 6fbd8b0d08acc35b8b8828506b2e0aec4e165a2e