KivyMD
KivyMD copied to clipboard
Disabling a MDButton and changing its position is not actually disabling it. (Except on clicking on text)
On trying to change the position of an MDButton with toggle behavior and set its default state to disabled, I could actually click inside the padding area of the button, and it is not disabled.
from kivymd.app import MDApp
from kivy.lang import Builder
KV="""
<ToggleMDButton@MDButton+ToggleButtonBehavior>:
MDFloatLayout:
ToggleMDButton:
disabled:True
pos_hint: {'center_x': 0.5,'center_y': 0.5}
radius:[dp(4),dp(4),dp(4),dp(4)]
theme_bg_color:"Custom"
md_bg_color:"red" if self.state=="normal" else "green"
theme_width: "Custom"
theme_height: "Custom"
size_hint:None,None
height:80
id:custom_button
text:"Custom button"
width: 200
state:"down"
MDButtonText:
pos_hint: {"center_x": .5, "center_y": .5}
text:self.parent.text
theme_text_color:"Custom"
text_color:'white'
text_color_disabled:'black'
"""
class MyApp(MDApp):
def build(self):
return Builder.load_string(KV)
if __name__=="__main__":
MyApp().run()