• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamewindowspythonphpguic翻訳omegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

ポータブルな Mekiku 互換ビューワ


Commit MetaInfo

Révision8dc1f5210a731e03d9ab813ba581b3d3909dc749 (tree)
l'heure2019-08-29 02:27:42
AuteurTAKAHASHI Tamotsu <ttakah+osdn@gmai...>
CommiterTAKAHASHI Tamotsu

Message de Log

delete trailing space after textedit is done

Change Summary

Modification

--- a/IMETextInput.py
+++ b/IMETextInput.py
@@ -1,29 +1,31 @@
11 __all__ = ("IMETextInput", )
22
33 from kivy.uix.textinput import TextInput
4-from kivy.properties import StringProperty
54 from kivy.base import EventLoop
65 from kivy.core.text.markup import MarkupLabel
76 from kivy.core.text import Label
87
98
109 class IMETextInput(TextInput):
11- editing = StringProperty()
12-
1310 def __init__(self, **kwargs):
1411 super(IMETextInput, self).__init__(**kwargs)
12+
1513 EventLoop.window.bind(on_textedit=self._on_textedit)
14+ self.editing = False
15+ self._spacehack = False
1616
1717 def _on_textedit(self, window, text):
18- self.editing = text
19- if len(text):
20- self.suggestion_text = "[" + text + "]"
21- else:
22- self.suggestion_text = ""
18+ self.editing = True if len(text) else False
19+ self.suggestion_text = text
20+
21+ # hack: see below for the reason
22+ if not self.editing and self._spacehack:
23+ self.text = self.text.rsplit(" ", 1)[0]
2324
2425 def keyboard_on_key_down(self, window, keycode, text, modifiers):
25- if len(self.editing):
26+ if self.editing:
2627 return True # IME consumes it all
28+
2729 super(IMETextInput, self).keyboard_on_key_down(
2830 window, keycode, text, modifiers)
2931
@@ -34,8 +36,9 @@ class IMETextInput(TextInput):
3436 # even when _lines_labels is given
3537 if not len(self._lines) or (
3638 len(self._lines) == 1 and not self._lines[0]):
37- self._set_text(" ") # hack: when should I delete it?
39+ self._set_text(" ")
3840 self.cursor = [0, 0]
41+ self._spacehack = True
3942
4043 cursor_row = self.cursor_row
4144 if cursor_row >= len(self._lines) or self.canvas is None:
@@ -52,7 +55,7 @@ class IMETextInput(TextInput):
5255 lbl = None
5356 if value:
5457 lbl = MarkupLabel(
55- text=pre + "[b]{}[/b]".format(value) + suf, **kw)
58+ text=pre + "[u]{}[/u]".format(value) + suf, **kw)
5659 else:
5760 lbl = Label(text=txt, **kw)
5861