【发布时间】:2020-09-24 12:39:28
【问题描述】:
我创建了多个标签按钮。我给了每一个“on_touch_up”属性,具有不同的功能。但是当我单击一个标签时,所有函数都会被调用。在我看来,可点击区域大于实际标签的纹理。 我尝试将这些标签的大小设置为不同的参数,例如“texture_size”或“font_size”,但没有成功。
感谢您的帮助
<YearLabel@ButtonBehavior+Label>
<YearScreen>:
canvas.before:
Color:
rgba: 1,1,1,0.25
Rectangle:
pos: self.pos
size: self.size
canvas.after:
Color:
rgba : 0,0,0,1
Rectangle:
pos: 160,1565
size: 419,60
BoxLayout:
id: years_layout
orientation: "vertical"
pos: 0,-2825
spacing: 380
YearLabel:
text: "2020"
font_size: "150sp"
color: 1,1,1,1
on_touch_up:
root.to_2020()
YearLabel:
text: "2021"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2021()
YearLabel:
text: "2022"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2022()
YearLabel:
text: "2023"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2023()
YearLabel:
text: "2024"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2024()
YearLabel:
text: "2025"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2025()
YearLabel:
text: "2026"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2026()
YearLabel:
text: "2027"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2027()
YearLabel:
text: "2028"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2028()
YearLabel:
text: "2029"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2029()
YearLabel:
text: "2030"
font_size: "150sp"
color: 0,0,0,1
on_touch_up:
root.to_2030()
【问题讨论】: