Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_chat.py @ 367:abb57182ebfb
chat: prepend nick to message input when occupant avatar is touched on group chat.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jan 2020 21:17:08 +0100 |
parents | 4d3a0c4f2430 |
children | 4d660b252487 |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Mon Jan 27 21:17:08 2020 +0100 @@ -24,6 +24,7 @@ from kivy.uix.textinput import TextInput from kivy.uix.screenmanager import Screen, NoTransition from kivy.uix import screenmanager +from kivy.uix.behaviors import ButtonBehavior from kivy.metrics import sp, dp from kivy.clock import Clock from kivy import properties @@ -73,7 +74,7 @@ INFINITE_SCROLL_LIMIT = dp(600) -class MessAvatar(Image): +class MessAvatar(ButtonBehavior, Image): pass @@ -455,6 +456,7 @@ return self.messages_widget.children ## keyboard ## + def key_input(self, window, key, scancode, codepoint, modifier): if key == 27: screen_manager = self.screen_manager @@ -650,6 +652,13 @@ room_jid=self.target) ) + # message input + + def addNick(self, nick): + """Add a nickname to message_input if suitable""" + if (self.type == C.CHAT_GROUP and not self.message_input.text.startswith(nick)): + self.message_input.text = f'{nick}: {self.message_input.text}' + def onSend(self, input_widget): G.host.messageSend( self.target,