Skip to content

Commit

Permalink
Fix setting twice the placeholder text
Browse files Browse the repository at this point in the history
The implementation of placeholder for GTK+-2 must manage the case when the
placeholder is set multiple times. So when setting placeholder, if it does not
have the focus and it contains the default placeholder, the text should be
removed to have _focus_out set the new placeholder.

issue6137
review25921003
(grafted from b640f28da4d565e64c901cff11eb34a4fb8ce76d)
  • Loading branch information
cedk committed Dec 27, 2016
1 parent a91db1a commit d64612f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tryton/common/placeholder_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _focus_out(self, event=None):
def set_placeholder_text(self, text):
self._placeholder = text
if not self.has_focus():
if self._default:
super(PlaceholderEntry, self).set_text('')
self._focus_out()

def get_text(self):
Expand Down Expand Up @@ -61,6 +63,8 @@ def cb(window, event):

placeholder_entry = PlaceholderEntry()
placeholder_entry.set_placeholder_text('Placeholder')
# Set twice to check placeholder does not become text
placeholder_entry.set_placeholder_text('Placeholder')
vbox.pack_start(placeholder_entry)

win.show_all()
Expand Down

0 comments on commit d64612f

Please sign in to comment.