问题描述
我在 ScatterLayout 中遇到拖放问题。单击地图内的按钮时,拖动不起作用。仅当起始位置不在按钮上时才会拖动地图。即使起点在按钮上,我该如何解决此问题并移动地图?
Вот мой код:
class IsoMapScreen(Screen): # Скрин карты
def __init__(self,**kw):
super(IsoMapScreen,self).__init__(**kw)
def on_enter(self,*args):
self.layout = RelativeLayout()
self.map = MyMap(source="data/maps/first.tmx") # Загруженная карта
self.map_scatter = MyScatterLayout() # Управление картой
self.map_lay = IsoFloatLayout(mymap=self.map) # Сама карта
self.map_scatter.add_widget(self.map_lay)
self.layout.add_widget(self.map_scatter)
class MyScatterLayout(ScatterPlaneLayout):
def __init__(self,**kwargs):
super(MyScatterLayout,self).__init__(**kwargs)
def on_touch_down(self,touch):
if touch.is_mouse_scrolling:
if touch.button == 'scrolldown':
self.zoom('down')
elif touch.button == 'scrollup':
self.zoom('up')
ScatterPlaneLayout.on_touch_down(self,touch)
class IsoFloatLayout(FloatLayout): # Слой карты
def __init__(self,mymap,**kwargs):
super(IsoFloatLayout,self).__init__(**kwargs)
self.moved = False
self.map = mymap
def on_touch_down(self,touch):
touch.grab(self)
return super(IsoFloatLayout,self).on_touch_down(touch)
def on_touch_move(self,touch):
if not self.moved:
self.moved = True
if touch.grab_current is self:
root_pos = self.parent.pos
return super(IsoFloatLayout,self).on_touch_move(touch)
def on_touch_up(self,touch):
if touch.grab_current is self:
touch.ungrab(self)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)