Ticket #4036: 0001-Auto-select-text-when-tap-click-on-title-entry-SL-40.patch

File 0001-Auto-select-text-when-tap-click-on-title-entry-SL-40.patch, 1.6 KB (added by humitos, 8 years ago)
  • src/sugar3/activity/widgets.py

    From a84e37b462b2bd8c9ae09d24bf859ec98fb4b76a Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Tue, 27 Nov 2012 19:42:51 -0300
    Subject: [PATCH sugar-toolkit-gtk3] Auto-select text when tap/click on title
     entry SL #4036
    
    When the user taps/clicks on the title entry inside the Activity
    Button, the text is selected automatically to change the whole
    title of the activity easily.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     src/sugar3/activity/widgets.py | 9 +++++++++
     1 file changed, 9 insertions(+)
    
    diff --git a/src/sugar3/activity/widgets.py b/src/sugar3/activity/widgets.py
    index 03b2415..9e552ed 100644
    a b class TitleEntry(Gtk.ToolItem): 
    178178        self.entry.set_size_request(int(Gdk.Screen.width() / 3), -1)
    179179        self.entry.set_text(activity.metadata['title'])
    180180        self.entry.connect('focus-out-event', self.__title_changed_cb, activity)
     181        self.entry.connect('button-press-event', self.__button_press_event_cb)
    181182        self.entry.show()
    182183        self.add(self.entry)
    183184
    class TitleEntry(Gtk.ToolItem): 
    203204        self.save_title(activity)
    204205        return False
    205206
     207    def __button_press_event_cb(self, widget, event):
     208        if widget.is_focus():
     209            return False
     210        else:
     211            widget.grab_focus()
     212            widget.select_region(0, -1)
     213            return True
     214
    206215    def save_title(self, activity):
    207216        title = self.entry.get_text()
    208217        if title == activity.metadata['title']: