KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

Disabled MDButton fires on_press events if pos_hint defined

Open cdavidson-project-canary opened this issue 4 months ago • 1 comments

Description of the Bug

A MDButton that is disabled will fire on_press events/callbacks if a pos_hint is applied to the button. The on_press events disappear when the pos_hint is removed.

Code and Logs


from kivy.clock import mainthread

from kivymd.app import MDApp
from kivymd.uix.button import MDButton, MDButtonText
from kivymd.uix.screen import MDScreen

class TestApp(MDApp):

    def build(self):
        screen = MDScreen()
        
        self.button = MDButton(
            pos_hint = {"center_x": 0.5, "center_y": 0.5},    # comment out this line and on_press events won't occur
            disabled = True
            )
        screen.add_widget(self.button)

        self.button.bind(on_press=lambda x: self.on_button_press())
        
        return screen
    #
    
    def on_button_press(self):
        print("button pressed")
    #
#

app = TestApp()
app.run()

Versions

OS: Windows 11 Enterprise Python: 3.10.11 Kivy: 2.3.0 KivyMD: 2.0.1.dev0