@@ -2344,17 +2344,22 @@ def _on_enter(self, event: events.Enter) -> None:
23442344 self .mouse_over = True
23452345
23462346 def _on_focus (self , event : events .Focus ) -> None :
2347- for node in self .ancestors_with_self :
2348- if node ._has_focus_within :
2349- self .app .update_styles (node )
23502347 self .has_focus = True
23512348 self .refresh ()
2349+ self .emit_no_wait (events .DescendantFocus (self ))
23522350
23532351 def _on_blur (self , event : events .Blur ) -> None :
2354- if any (node ._has_focus_within for node in self .ancestors_with_self ):
2355- self .app .update_styles (self )
23562352 self .has_focus = False
23572353 self .refresh ()
2354+ self .emit_no_wait (events .DescendantBlur (self ))
2355+
2356+ def _on_descendant_blur (self , event : events .DescendantBlur ) -> None :
2357+ if self ._has_focus_within :
2358+ self .app .update_styles (self )
2359+
2360+ def _on_descendant_focus (self , event : events .DescendantBlur ) -> None :
2361+ if self ._has_focus_within :
2362+ self .app .update_styles (self )
23582363
23592364 def _on_mouse_scroll_down (self , event ) -> None :
23602365 if self .allow_vertical_scroll :
@@ -2398,34 +2403,42 @@ def _on_hide(self, event: events.Hide) -> None:
23982403 def _on_scroll_to_region (self , message : messages .ScrollToRegion ) -> None :
23992404 self .scroll_to_region (message .region , animate = True )
24002405
2401- def action_scroll_home (self ) -> None :
2402- if self ._allow_scroll :
2403- self .scroll_home ()
2404-
2405- def action_scroll_end (self ) -> None :
2406- if self ._allow_scroll :
2407- self .scroll_end ()
2408-
2409- def action_scroll_left (self ) -> None :
2410- if self .allow_horizontal_scroll :
2411- self .scroll_left ()
2412-
2413- def action_scroll_right (self ) -> None :
2414- if self .allow_horizontal_scroll :
2415- self .scroll_right ()
2416-
2417- def action_scroll_up (self ) -> None :
2418- if self .allow_vertical_scroll :
2419- self .scroll_up ()
2420-
2421- def action_scroll_down (self ) -> None :
2422- if self .allow_vertical_scroll :
2423- self .scroll_down ()
2424-
2425- def action_page_down (self ) -> None :
2426- if self .allow_vertical_scroll :
2427- self .scroll_page_down ()
2428-
2429- def action_page_up (self ) -> None :
2430- if self .allow_vertical_scroll :
2431- self .scroll_page_up ()
2406+ def action_scroll_home (self ) -> bool | None :
2407+ if not self ._allow_scroll :
2408+ return False
2409+ self .scroll_home ()
2410+
2411+ def action_scroll_end (self ) -> bool | None :
2412+ if not self ._allow_scroll :
2413+ return False
2414+ self .scroll_end ()
2415+
2416+ def action_scroll_left (self ) -> bool | None :
2417+ if not self .allow_horizontal_scroll :
2418+ return False
2419+ self .scroll_left ()
2420+
2421+ def action_scroll_right (self ) -> bool | None :
2422+ if not self .allow_horizontal_scroll :
2423+ return False
2424+ self .scroll_right ()
2425+
2426+ def action_scroll_up (self ) -> bool | None :
2427+ if not self .allow_vertical_scroll :
2428+ return False
2429+ self .scroll_up ()
2430+
2431+ def action_scroll_down (self ) -> bool | None :
2432+ if not self .allow_vertical_scroll :
2433+ return False
2434+ self .scroll_down ()
2435+
2436+ def action_page_down (self ) -> bool | None :
2437+ if not self .allow_vertical_scroll :
2438+ return False
2439+ self .scroll_page_down ()
2440+
2441+ def action_page_up (self ) -> bool | None :
2442+ if not self .allow_vertical_scroll :
2443+ return False
2444+ self .scroll_page_up ()
0 commit comments