kvex.widgets.input
Home of XInput
.
1"""Home of `XInput`.""" 2 3from .. import kivy as kv 4from ..behaviors import XThemed, XFocusBehavior 5from .widget import XWidget 6 7 8class XInput(XThemed, XFocusBehavior, XWidget, kv.TextInput): 9 """TextInput with sane defaults.""" 10 11 select_on_focus = kv.BooleanProperty(False) 12 deselect_on_escape = kv.BooleanProperty(True) 13 14 def __init__(self, **kwargs): 15 """Initialize the class.""" 16 kwargs = dict( 17 multiline=False, 18 text_validate_unfocus=False, 19 write_tab=False, 20 ) | kwargs 21 super().__init__(**kwargs) 22 23 def _on_textinput_focused(self, *args, **kwargs): 24 """Overrides base method to handle selection on focus.""" 25 r = super()._on_textinput_focused(*args, **kwargs) 26 if self.focus and self.select_on_focus: 27 self.select_all() 28 return r 29 30 def reset_cursor_selection(self, *a): 31 """Resets the cursor position and selection.""" 32 self.cancel_selection() 33 self.cursor = 0, 0 34 self.scroll_x = 0 35 self.scroll_y = 0 36 37 def keyboard_on_key_down(self, w, key_pair, text, mods): 38 """Override base method to deselect on escape.""" 39 keycode, key = key_pair 40 if key == "escape": 41 if self.deselect_on_escape: 42 self.cancel_selection() 43 return True 44 return super().keyboard_on_key_down(w, key_pair, text, mods) 45 46 def on_subtheme(self, subtheme): 47 """Apply colors.""" 48 self.background_color = subtheme.bg.rgba 49 self.foreground_color = subtheme.fg.rgba 50 51 52__all__ = ( 53 "XInput", 54)
class
XInput(kvex.behaviors.XThemed, kvex.behaviors.XFocusBehavior, kvex.widgets.widget.XWidget, kivy.uix.textinput.TextInput):
9class XInput(XThemed, XFocusBehavior, XWidget, kv.TextInput): 10 """TextInput with sane defaults.""" 11 12 select_on_focus = kv.BooleanProperty(False) 13 deselect_on_escape = kv.BooleanProperty(True) 14 15 def __init__(self, **kwargs): 16 """Initialize the class.""" 17 kwargs = dict( 18 multiline=False, 19 text_validate_unfocus=False, 20 write_tab=False, 21 ) | kwargs 22 super().__init__(**kwargs) 23 24 def _on_textinput_focused(self, *args, **kwargs): 25 """Overrides base method to handle selection on focus.""" 26 r = super()._on_textinput_focused(*args, **kwargs) 27 if self.focus and self.select_on_focus: 28 self.select_all() 29 return r 30 31 def reset_cursor_selection(self, *a): 32 """Resets the cursor position and selection.""" 33 self.cancel_selection() 34 self.cursor = 0, 0 35 self.scroll_x = 0 36 self.scroll_y = 0 37 38 def keyboard_on_key_down(self, w, key_pair, text, mods): 39 """Override base method to deselect on escape.""" 40 keycode, key = key_pair 41 if key == "escape": 42 if self.deselect_on_escape: 43 self.cancel_selection() 44 return True 45 return super().keyboard_on_key_down(w, key_pair, text, mods) 46 47 def on_subtheme(self, subtheme): 48 """Apply colors.""" 49 self.background_color = subtheme.bg.rgba 50 self.foreground_color = subtheme.fg.rgba
TextInput with sane defaults.
XInput(**kwargs)
15 def __init__(self, **kwargs): 16 """Initialize the class.""" 17 kwargs = dict( 18 multiline=False, 19 text_validate_unfocus=False, 20 write_tab=False, 21 ) | kwargs 22 super().__init__(**kwargs)
Initialize the class.
select_on_focus
BooleanProperty(defaultvalue=True, **kw) Property that represents only a boolean value.
:Parameters:
`defaultvalue`: boolean
Specifies the default value of the property.
deselect_on_escape
BooleanProperty(defaultvalue=True, **kw) Property that represents only a boolean value.
:Parameters:
`defaultvalue`: boolean
Specifies the default value of the property.
def
reset_cursor_selection(self, *a):
31 def reset_cursor_selection(self, *a): 32 """Resets the cursor position and selection.""" 33 self.cancel_selection() 34 self.cursor = 0, 0 35 self.scroll_x = 0 36 self.scroll_y = 0
Resets the cursor position and selection.
def
keyboard_on_key_down(self, w, key_pair, text, mods):
38 def keyboard_on_key_down(self, w, key_pair, text, mods): 39 """Override base method to deselect on escape.""" 40 keycode, key = key_pair 41 if key == "escape": 42 if self.deselect_on_escape: 43 self.cancel_selection() 44 return True 45 return super().keyboard_on_key_down(w, key_pair, text, mods)
Override base method to deselect on escape.
def
on_subtheme(self, subtheme):
47 def on_subtheme(self, subtheme): 48 """Apply colors.""" 49 self.background_color = subtheme.bg.rgba 50 self.foreground_color = subtheme.fg.rgba
Apply colors.
Inherited Members
- kivy.uix.textinput.TextInput
- is_focusable
- selection_text
- on_text_validate
- cursor_index
- cursor_offset
- get_cursor_from_index
- select_text
- select_all
- insert_text
- reset_undo
- do_redo
- do_undo
- do_backspace
- pgmove_speed
- do_cursor_movement
- get_cursor_from_xy
- cancel_selection
- delete_selection
- long_touch
- cancel_long_touch_event
- on_double_tap
- on_triple_tap
- on_quad_touch
- on_touch_down
- on_touch_move
- on_touch_up
- scroll_text_from_swipe
- cut
- copy
- paste
- on_cursor_blink
- on_cursor
- on_size
- keyboard_on_textinput
- window_on_textedit
- on__hint_text
- readonly
- text_validate_unfocus
- multiline
- do_wrap
- password
- password_mask
- cursor_blink
- cursor
- cursor_col
- cursor_row
- cursor_pos
- cursor_color
- cursor_width
- line_height
- tab_width
- padding_x
- on_padding_x
- padding_y
- on_padding_y
- padding
- halign
- scroll_x
- scroll_y
- selection_color
- border
- background_normal
- background_disabled_normal
- background_active
- background_color
- foreground_color
- disabled_foreground_color
- use_bubble
- use_handles
- scroll_from_swipe
- scroll_distance
- scroll_timeout
- get_sel_from
- selection_from
- get_sel_to
- selection_to
- on_selection_text
- text
- font_name
- font_size
- font_context
- font_family
- base_direction
- text_language
- hint_text
- hint_text_color
- auto_indent
- replace_crlf
- allow_copy
- minimum_height
- line_spacing
- input_filter
- handle_image_middle
- on_handle_image_middle
- handle_image_left
- on_handle_image_left
- handle_image_right
- on_handle_image_right
- write_tab
- kivy.uix.behaviors.focus.FocusBehavior
- ignored_touch
- keyboard
- focus
- focused
- keyboard_suggestions
- focus_next
- focus_previous
- keyboard_mode
- input_type
- unfocus_on_touch
- get_focus_next
- get_focus_previous
- show_keyboard
- hide_keyboard
- kivy.uix.widget.Widget
- proxy_ref
- apply_class_lang_rules
- collide_point
- collide_widget
- on_motion
- on_kv_post
- add_widget
- remove_widget
- clear_widgets
- register_for_motion_event
- unregister_for_motion_event
- export_to_png
- export_as_image
- get_root_window
- get_parent_window
- walk
- walk_reverse
- to_widget
- to_window
- to_parent
- to_local
- get_window_matrix
- x
- y
- width
- height
- pos
- size
- get_right
- set_right
- right
- get_top
- set_top
- top
- get_center_x
- set_center_x
- center_x
- get_center_y
- set_center_y
- center_y
- center
- cls
- children
- parent
- size_hint_x
- size_hint_y
- size_hint
- pos_hint
- size_hint_min_x
- size_hint_min_y
- size_hint_min
- size_hint_max_x
- size_hint_max_y
- size_hint_max
- ids
- opacity
- on_opacity
- canvas
- get_disabled
- set_disabled
- inc_disabled
- dec_disabled
- disabled
- motion_filter
- kivy._event.EventDispatcher
- register_event_type
- unregister_event_types
- unregister_event_type
- is_event_type
- bind
- unbind
- fbind
- funbind
- unbind_uid
- get_property_observers
- events
- dispatch
- dispatch_generic
- dispatch_children
- setter
- getter
- property
- properties
- create_property
- apply_property