comparison cagou/core/behaviors.py @ 491:203755bbe0fe

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:32 +0200
parents 3c9ba4a694ef
children
comparison
equal deleted inserted replaced
490:962d17c4078c 491:203755bbe0fe
32 class TouchMenuItemBehavior: 32 class TouchMenuItemBehavior:
33 """Class to use on every item where a menu may appear 33 """Class to use on every item where a menu may appear
34 34
35 main_wid attribute must be set to the class inheriting from TouchMenuBehavior 35 main_wid attribute must be set to the class inheriting from TouchMenuBehavior
36 do_item_action is the method called on simple click 36 do_item_action is the method called on simple click
37 getMenuChoices must return a list of menus for long press 37 get_menu_choices must return a list of menus for long press
38 menus there are dict as expected by ModernMenu 38 menus there are dict as expected by ModernMenu
39 (translated text, index and callback) 39 (translated text, index and callback)
40 """ 40 """
41 main_wid = properties.ObjectProperty() 41 main_wid = properties.ObjectProperty()
42 click_timeout = properties.NumericProperty(0.4) 42 click_timeout = properties.NumericProperty(0.4)
61 61
62 def open_menu(self, touch, dt): 62 def open_menu(self, touch, dt):
63 self.main_wid.open_menu(self, touch) 63 self.main_wid.open_menu(self, touch)
64 del touch.ud['menu_timeout'] 64 del touch.ud['menu_timeout']
65 65
66 def getMenuChoices(self): 66 def get_menu_choices(self):
67 """return choice adapted to selected item 67 """return choice adapted to selected item
68 68
69 @return (list[dict]): choices ad expected by ModernMenu 69 @return (list[dict]): choices ad expected by ModernMenu
70 """ 70 """
71 return [] 71 return []
106 """ 106 """
107 if self.menu_item == item: 107 if self.menu_item == item:
108 return 108 return
109 self.clear_menu() 109 self.clear_menu()
110 pos = self.to_widget(*touch.pos) 110 pos = self.to_widget(*touch.pos)
111 choices = item.getMenuChoices() 111 choices = item.get_menu_choices()
112 if not choices: 112 if not choices:
113 return 113 return
114 self.menu = TouchMenu(choices=choices, 114 self.menu = TouchMenu(choices=choices,
115 center=pos, 115 center=pos,
116 size_hint=(None, None)) 116 size_hint=(None, None))