Finished refactoring menu showing, now also sense editing works!
This commit is contained in:
24
src/message/show_menu.py
Normal file
24
src/message/show_menu.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from model import Translation, Sense
|
||||
from message.simple_messages import ClickMessage
|
||||
|
||||
|
||||
class ShowMenu(ClickMessage):
|
||||
def on_event(self, event):
|
||||
location_x = event.currentTarget.offsetLeft
|
||||
location_y = event.currentTarget.offsetTop + event.currentTarget.offsetHeight
|
||||
self.menu_location = (location_x, location_y)
|
||||
super().on_event(event)
|
||||
|
||||
|
||||
class ShowTranslationMenu(ShowMenu):
|
||||
def update_model(self, model):
|
||||
model.menu_location = self.menu_location
|
||||
model.translation = self.get_arg(0, Translation)
|
||||
model.menu_target = model.translation
|
||||
|
||||
|
||||
class ShowSenseMenu(ShowMenu):
|
||||
def update_model(self, model):
|
||||
model.menu_location = self.menu_location
|
||||
sense = self.get_arg(0, Sense)
|
||||
model.menu_target = sense
|
||||
Reference in New Issue
Block a user