Add behavior for "long backspace" press in keyboard
what this actually does must be specified by parent i guess, so far that is in 2 places. if many more would be nice to standardize that a bit more somehow
This commit is contained in:
		
							parent
							
								
									78e6704639
								
							
						
					
					
						commit
						32fc71691e
					
				
					 3 changed files with 25 additions and 4 deletions
				
			
		|  | @ -117,7 +117,8 @@ class WuttaCustomerLookup(WuttaControl): | |||
|                     ], | ||||
|                 ), | ||||
|                 ft.Divider(), | ||||
|                 WuttaKeyboard(self.config, on_keypress=self.keypress), | ||||
|                 WuttaKeyboard(self.config, on_keypress=self.keypress, | ||||
|                               on_long_backspace=self.long_backspace), | ||||
|                 ft.Divider(), | ||||
|                 ft.Row( | ||||
|                     [ | ||||
|  | @ -162,6 +163,11 @@ class WuttaCustomerLookup(WuttaControl): | |||
|             self.searchbox.focus() | ||||
|             self.update() | ||||
| 
 | ||||
|     def long_backspace(self): | ||||
|         self.searchbox.value = self.searchbox.value[:-10] | ||||
|         self.searchbox.focus() | ||||
|         self.update() | ||||
| 
 | ||||
|     def lookup(self, e=None): | ||||
|         entry = self.searchbox.value | ||||
|         if not entry: | ||||
|  |  | |||
|  | @ -71,7 +71,8 @@ class WuttaFeedback(WuttaControl): | |||
|                         ft.Divider(), | ||||
|                         self.message, | ||||
|                         ft.Divider(), | ||||
|                         WuttaKeyboard(self.config, on_keypress=self.keypress), | ||||
|                         WuttaKeyboard(self.config, on_keypress=self.keypress, | ||||
|                                       on_long_backspace=self.long_backspace), | ||||
|                     ], | ||||
|                     expand=True, | ||||
|                 ), | ||||
|  | @ -121,6 +122,11 @@ class WuttaFeedback(WuttaControl): | |||
|         self.message.focus() | ||||
|         self.update() | ||||
| 
 | ||||
|     def long_backspace(self): | ||||
|         self.message.value = self.message.value[:-10] | ||||
|         self.message.focus() | ||||
|         self.update() | ||||
| 
 | ||||
|     def cancel(self, e): | ||||
|         self.dlg.open = False | ||||
|         self.page.update() | ||||
|  |  | |||
|  | @ -36,6 +36,7 @@ class WuttaKeyboard(WuttaControl): | |||
| 
 | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         self.on_keypress = kwargs.pop('on_keypress', None) | ||||
|         self.on_long_backspace = kwargs.pop('on_long_backspace', None) | ||||
| 
 | ||||
|         super().__init__(*args, **kwargs) | ||||
| 
 | ||||
|  | @ -127,10 +128,16 @@ class WuttaKeyboard(WuttaControl): | |||
|         if self.shift: | ||||
|             self.update_shift(False) | ||||
| 
 | ||||
|     def long_backspace(self, e): | ||||
|         if self.on_long_backspace: | ||||
|             self.on_long_backspace() | ||||
| 
 | ||||
|     def build(self): | ||||
|         self.keys = {} | ||||
| 
 | ||||
|         def make_key(key, data=None, on_click=self.simple_keypress, | ||||
|         def make_key(key, data=None, | ||||
|                      on_click=self.simple_keypress, | ||||
|                      on_long_press=None, | ||||
|                      width=self.default_button_size, | ||||
|                      bgcolor=None): | ||||
|             button = ft.Container(content=ft.Text(key, size=self.default_font_size, | ||||
|  | @ -139,6 +146,7 @@ class WuttaKeyboard(WuttaControl): | |||
|                                   height=self.default_button_size, | ||||
|                                   width=width, | ||||
|                                   on_click=on_click, | ||||
|                                   on_long_press=on_long_press, | ||||
|                                   alignment=ft.alignment.center, | ||||
|                                   border=ft.border.all(1, 'black'), | ||||
|                                   border_radius=ft.border_radius.all(5), | ||||
|  | @ -162,7 +170,8 @@ class WuttaKeyboard(WuttaControl): | |||
|             self.shift_key.bgcolor = 'blue' | ||||
| 
 | ||||
|         rows = [ | ||||
|             [make_key(k) for k in "`1234567890-="] + [make_key('⌫', bgcolor='yellow')], | ||||
|             [make_key(k) for k in "`1234567890-="] + [make_key('⌫', bgcolor='yellow', | ||||
|                                                                on_long_press=self.long_backspace)], | ||||
|             [make_key(k) for k in "qwertyuiop[]\\"], | ||||
|             [self.caps_key] + [make_key(k) for k in "asdfghjkl;'"] + [make_key('⏎', bgcolor='blue')], | ||||
|             [self.shift_key] + [make_key(k) for k in "zxcvbnm,./"], | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar