久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='4iMc2'></small><noframes id='4iMc2'>

  • <tfoot id='4iMc2'></tfoot>

    <i id='4iMc2'><tr id='4iMc2'><dt id='4iMc2'><q id='4iMc2'><span id='4iMc2'><b id='4iMc2'><form id='4iMc2'><ins id='4iMc2'></ins><ul id='4iMc2'></ul><sub id='4iMc2'></sub></form><legend id='4iMc2'></legend><bdo id='4iMc2'><pre id='4iMc2'><center id='4iMc2'></center></pre></bdo></b><th id='4iMc2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4iMc2'><tfoot id='4iMc2'></tfoot><dl id='4iMc2'><fieldset id='4iMc2'></fieldset></dl></div>

    <legend id='4iMc2'><style id='4iMc2'><dir id='4iMc2'><q id='4iMc2'></q></dir></style></legend>

          <bdo id='4iMc2'></bdo><ul id='4iMc2'></ul>

        Kivy:使用“on focus"或“on_touch_down"清除文本

        Kivy: Clearing Text Input with #39;on focus#39; or #39;on_touch_down#39;(Kivy:使用“on focus或“on_touch_down清除文本輸入)
          <bdo id='8fDId'></bdo><ul id='8fDId'></ul>

              <tfoot id='8fDId'></tfoot>

            • <legend id='8fDId'><style id='8fDId'><dir id='8fDId'><q id='8fDId'></q></dir></style></legend>
            • <i id='8fDId'><tr id='8fDId'><dt id='8fDId'><q id='8fDId'><span id='8fDId'><b id='8fDId'><form id='8fDId'><ins id='8fDId'></ins><ul id='8fDId'></ul><sub id='8fDId'></sub></form><legend id='8fDId'></legend><bdo id='8fDId'><pre id='8fDId'><center id='8fDId'></center></pre></bdo></b><th id='8fDId'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8fDId'><tfoot id='8fDId'></tfoot><dl id='8fDId'><fieldset id='8fDId'></fieldset></dl></div>

              • <small id='8fDId'></small><noframes id='8fDId'>

                  <tbody id='8fDId'></tbody>
                  本文介紹了Kivy:使用“on focus"或“on_touch_down"清除文本輸入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想在單擊 TextInputtext: 時清除它.示例代碼:

                  I want to clear a TextInput's text: when I click on it. Sample Code:

                  from kivy.app import App
                  from kivy.lang import Builder
                  
                  kv_string = """
                  ScreenManager:
                      id: manager
                      Screen:
                          BoxLayout:
                              orientation: 'vertical'
                              Button:
                                  text: 'Why does it clear multiple inputs? And why do they get cleared after touch_up?'
                              TextInput:
                                  text: 'Write Your Name'
                                  on_touch_down:
                                      self.text = ''
                  
                              TextInput:
                                  text: 'Write Your Last Name'
                                  on_focus:
                                      self.text = ''
                  
                              TextInput:
                                  text: 'Write Your Phone Number'
                                  on_touch_down:
                                      self.text = ''
                  """
                  
                  class MyApp(App):
                  
                      def build(self):
                          root_widget = Builder.load_string(kv_string)
                          return root_widget
                  
                  if __name__ == "__main__":
                      MyApp().run()
                  

                  on_touch_down:on_focus 都不會刪除當前聚焦的文本輸入.相反,當我觸摸屏幕上的任何位置時,兩者都會被清除.一旦光標位于文本輸入上,我希望它們單獨清除.我也試過 on_cursor 但這也沒有用.我錯過了什么?提前致謝!

                  Neither on_touch_down: or on_focus erases JUST the text input that is currently focused. Instead, both get cleared when I touch anywhere on the screen. I would want them cleared individually once the cursor is on a text input. I also tried on_cursor but that didn't work either. What am I missing? Thank you in advance!

                  推薦答案

                  on_touch_down 事件被所有小部件接收,直到一個返回 True 告訴事件循環它正在使用它,因此沒有將其發送到 文檔:

                  The on_touch_down event is received by all the widgets until one returns True telling the event-loop that it is using it and thus not send it to other widgets as indicated by the docs:

                  on_touch_down(touch) 在 1.0.0 中添加

                  on_touch_down(touch) Added in 1.0.0

                  接收觸地事件.

                  參數:

                  touch: MotionEvent 類 Touch 收到.

                  touch: MotionEvent class Touch received.

                  觸摸在父坐標中.有關坐標的討論,請參見 relativelayout系統.

                  The touch is in parent coordinates. See relativelayout for a discussion on coordinate systems.

                  返回:

                  bool 如果為 True,則觸摸事件的調度將停止.如果為 False,則該事件將繼續分派給其余的小部件樹.

                  bool If True, the dispatching of the touch event will stop. If False, the event will continue to be dispatched to the rest of the widget tree.

                  on_touch_down 的經典用法是在 python 中,因為 kv 語言在方法覆蓋方面受到限制:

                  The classic use of on_touch_down is in python since kv language is limited in the overwriting of methods:

                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.textinput import TextInput
                  
                  class MyTextInput(TextInput):
                      def on_touch_down(self, touch):
                          if self.collide_point(*touch.pos):
                              self.text = ""
                              return True
                          return super(MyTextInput, self).on_touch_down(touch)
                  
                  kv_string = """
                  ScreenManager:
                      id: manager
                      Screen:
                          BoxLayout:
                              orientation: 'vertical'
                              Button:
                                  text: 'Why does it clear multiple inputs? And why do they get cleared after touch_up?'
                              MyTextInput:
                                  text: 'Write Your Name'
                              MyTextInput:
                                  text: 'Write Your Last Name'  
                              MyTextInput:
                                  text: 'Write Your Phone Number'
                  """
                  
                  class MyApp(App):
                      def build(self):
                          root_widget = Builder.load_string(kv_string)
                          return root_widget
                  
                  if __name__ == "__main__":
                      MyApp().run()
                  

                  或 .kv 中的等價物,但最重要的是你不能返回 True.

                  Or something equivalent in .kv but the devestaja is that you can not return True.

                  kv_string = """
                  ScreenManager:
                      id: manager
                      Screen:
                          BoxLayout:
                              orientation: 'vertical'
                              Button:
                                  text: 'Why does it clear multiple inputs? And why do they get cleared after touch_up?'
                              TextInput:
                                  text: 'Write Your Name'
                                  on_touch_down: if self.collide_point(*args[1].pos): self.text = ""
                              TextInput:
                                  text: 'Write Your Last Name'
                                  on_touch_down: if self.collide_point(*args[1].pos): self.text = ""
                              TextInput:
                                  text: 'Write Your Phone Number'
                                  on_touch_down: if self.collide_point(*args[1].pos): self.text = ""
                  """
                  

                  所以你應該使用 on_focus,它是一個與 FocusBehavior 關聯的事件,它會覆蓋 on_touch_down 使用 self.collide_point(*touch.pos) 進行驗證.

                  So you should use on_focus which is an event associated to FocusBehavior that overwrites on_touch_down verifying using self.collide_point(*touch.pos).

                  from kivy.app import App
                  from kivy.lang import Builder
                  
                  kv_string = """
                  ScreenManager:
                      id: manager
                      Screen:
                          BoxLayout:
                              orientation: 'vertical'
                              Button:
                                  text: 'Why does it clear multiple inputs? And why do they get cleared after touch_up?'
                              TextInput:
                                  text: 'Write Your Name'
                                  on_focus: self.text = ""
                              TextInput:
                                  text: 'Write Your Last Name'
                                  on_focus: self.text = ""
                              TextInput:
                                  text: 'Write Your Phone Number'
                                  on_focus: self.text = ""
                  """
                  
                  class MyApp(App):
                      def build(self):
                          root_widget = Builder.load_string(kv_string)
                          return root_widget
                  
                  if __name__ == "__main__":
                      MyApp().run()
                  

                  這篇關于Kivy:使用“on focus"或“on_touch_down"清除文本輸入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                1. <tfoot id='imxmh'></tfoot>

                    <small id='imxmh'></small><noframes id='imxmh'>

                    <legend id='imxmh'><style id='imxmh'><dir id='imxmh'><q id='imxmh'></q></dir></style></legend>
                    • <i id='imxmh'><tr id='imxmh'><dt id='imxmh'><q id='imxmh'><span id='imxmh'><b id='imxmh'><form id='imxmh'><ins id='imxmh'></ins><ul id='imxmh'></ul><sub id='imxmh'></sub></form><legend id='imxmh'></legend><bdo id='imxmh'><pre id='imxmh'><center id='imxmh'></center></pre></bdo></b><th id='imxmh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='imxmh'><tfoot id='imxmh'></tfoot><dl id='imxmh'><fieldset id='imxmh'></fieldset></dl></div>
                        <tbody id='imxmh'></tbody>

                            <bdo id='imxmh'></bdo><ul id='imxmh'></ul>
                            主站蜘蛛池模板: 一区福利视频 | 午夜精品久久久久久不卡欧美一级 | 欧美二级 | 国产精品免费看 | 少妇无套高潮一二三区 | 91亚洲精 | 亚洲永久精品国产 | 亚洲一区二区三区免费视频 | 国产一区二区三区四区hd | 日韩视频在线一区 | www久久| 色综合99| 日韩区 | 国产精品日韩欧美一区二区 | 国产精品99久久久久久宅男 | 久久久99国产精品免费 | 午夜影院在线观看免费 | 一区二区三区在线 | 成人欧美一区二区三区在线观看 | 狠狠婷婷综合久久久久久妖精 | 亚洲九九 | 欧美黑人一区二区三区 | 精品欧美乱码久久久久久1区2区 | 97日日碰人人模人人澡分享吧 | 日韩一区三区 | 亚洲精品乱码8久久久久久日本 | 婷婷色成人| 老熟女毛片 | 国产a区| 91九色视频| 欧美精品久久 | 久久99精品久久久久久青青日本 | 亚洲国产一区二区三区 | 亚洲一区二区久久 | 日韩欧美高清 | 精品久久久久久久人人人人传媒 | 亚洲第一在线 | 国产日韩欧美 | 欧美成人一级 | 国产精品一区二区欧美黑人喷潮水 | av首页在线|