Note that there are some explanatory texts on larger screens.

plurals
  1. POdetecting click/touch in kivy textinput
    primarykey
    data
    text
    <p>I have a textinput that I want to focus on when the user clicks/touches on it. (Fairly standard!) It inherits from DragableObject (a user example in the kivy wiki) and GridLayout.</p> <pre><code>class DragableObject( Widget ): def on_touch_down( self, touch ): if self.collide_point( *touch.pos ): touch.grab( self ) return True def on_touch_up( self, touch ): if touch.grab_current is self: touch.ungrab( self ) return True def on_touch_move( self, touch ): if touch.grab_current is self: self.pos = touch.x-self.width/2, touch.y-self.height/2 class MyWidget(DragableObject, GridLayout): def __init__(self, **kwargs): kwargs['orientation'] = 'lr-tb' kwargs['spacing'] = 10 kwargs['size_hint'] = (None, None) kwargs['size'] = (200, 80) self.cols = 2 super(MyWidget, self).__init__(**kwargs) with self.canvas: self.rect = Rectangle(pos=self.pos, size=self.size) with self.canvas.before: Color(0, .5, 1, mode='rgb') self.bind(pos=self.update_rect) self.bind(size=self.update_rect) self.add_widget(Label(text='t1')) self.text1 = TextInput(multiline=False) self.add_widget(self.text1) self.add_widget(Label(text='t2')) self.text2 = TextInput(multiline=False) self.add_widget(self.text2) # these bind's don't seem to work self.text1.bind(on_touch_down=self.set_focus) self.text1.bind(on_touch_up=self.set_focus) self.text1.bind(on_touch_move=self.set_focus) def set_focus(self): print("pressed") self.text1.focus = True def update_rect(self, *args): self.rect.pos = self.pos self.rect.size = self.size </code></pre> <p>I have two problems.</p> <p>a. The text input is unfocusable.</p> <p>b. I can't get an event callback (such as on_touch_down) to work on the textinput widget.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload