KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

FocusBehavior incoherent between Kivy and KivyMD

Open cederom opened this issue 2 years ago • 3 comments

Description of the Bug

  • Kivy FocusBehavior mixin focuses on Tab switching between components (https://kivy.org/doc/stable/api-kivy.uix.behaviors.focus.html).
  • KivyMD FocusBehavior mixin focuses only on mouse-over (https://kivymd.readthedocs.io/en/1.1.1/behaviors/focus/).
  • This makes FocusBehavior incoherent between Kivy and KivyMD.
  • Also it is a bit hard to join these two mixins with the same name (import .. as is required).
  • Is this intentional?
  • If this is intentional why not name MDFocusBehavior like the rest of the KivyMD components?

Code and Logs

  • Kivy FocusBehavior source: https://github.com/kivy/kivy/blob/master/kivy/uix/behaviors/focus.py.
  • KivyMD FocusBehavior source: https://github.com/KivyMD/KivyMD/blob/master/kivymd/uix/behaviors/focus_behavior.py

Screenshots

Why not replace current KivyMD code:

from kivy.app import App
from kivy.properties import BooleanProperty, ColorProperty
from kivy.uix.behaviors import ButtonBehavior

from kivymd.uix.behaviors import HoverBehavior

class FocusBehavior(HoverBehavior, ButtonBehavior):
(...)

with:

from kivy.app import App
from kivy.properties import BooleanProperty, ColorProperty
from kivy.uix.behaviors import ButtonBehavior

from kivymd.uix.behaviors import HoverBehavior
from kivymd.uix.behaviors import FocusBehavior

class MDFocusBehavior(FocusBehavior, HoverBehavior, ButtonBehavior):
(...)

Versions

  • OS: FreeBSD octagon 13.1-STABLE FreeBSD 13.1-STABLE #0 stable/13-n253075-2b20cade1eca: Sun Nov 13 20:06:09 CET 2022 root@octagon:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64.
  • Python: 3.9.15.
  • Kivy: 2.1.0.
  • KivyMD: 1.1.1.

cederom avatar Dec 05 '22 02:12 cederom

Hey there @HeaTTheatR :-)

This issue is not completed. It shoud be reopened and resolved.

  • There are two things (both in Kivy and KivyMD) with the same name doing different jobs.
  • There are import errors and inconsistencies with documentation.
  • I would strongly recommend to rename KivyMD's FocusBehavior to MDFocusBehavior.
  • With two different names new classes may be created with both features with no namespace confusion.

Thanks :-)

cederom avatar Dec 05 '22 19:12 cederom

Thanks @HeaTTheatR :-) I can provide some patches.. are there other things to consider except the name change? :-)

cederom avatar Dec 05 '22 20:12 cederom

@cederom We need to test all library modules that use the FocusBehavior class.

HeaTTheatR avatar Dec 05 '22 20:12 HeaTTheatR