Activity title entry: auto-select text when tap/click in the entry, SL #4036
When the user taps/clicks in the activity title entry, the text is selected automatically to change the whole title of the activity easily. Signed-off-by: Manuel Kaufmann <humitos@gmail.com> Acked-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
parent
d87967303c
commit
7b8fa5e406
@ -178,6 +178,7 @@ class TitleEntry(Gtk.ToolItem):
|
|||||||
self.entry.set_size_request(int(Gdk.Screen.width() / 3), -1)
|
self.entry.set_size_request(int(Gdk.Screen.width() / 3), -1)
|
||||||
self.entry.set_text(activity.metadata['title'])
|
self.entry.set_text(activity.metadata['title'])
|
||||||
self.entry.connect('focus-out-event', self.__title_changed_cb, activity)
|
self.entry.connect('focus-out-event', self.__title_changed_cb, activity)
|
||||||
|
self.entry.connect('button-press-event', self.__button_press_event_cb)
|
||||||
self.entry.show()
|
self.entry.show()
|
||||||
self.add(self.entry)
|
self.add(self.entry)
|
||||||
|
|
||||||
@ -203,6 +204,14 @@ class TitleEntry(Gtk.ToolItem):
|
|||||||
self.save_title(activity)
|
self.save_title(activity)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def __button_press_event_cb(self, widget, event):
|
||||||
|
if widget.is_focus():
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
widget.grab_focus()
|
||||||
|
widget.select_region(0, -1)
|
||||||
|
return True
|
||||||
|
|
||||||
def save_title(self, activity):
|
def save_title(self, activity):
|
||||||
title = self.entry.get_text()
|
title = self.entry.get_text()
|
||||||
if title == activity.metadata['title']:
|
if title == activity.metadata['title']:
|
||||||
|
Loading…
Reference in New Issue
Block a user