Giter Club home page Giter Club logo

Comments (6)

TomJGooding avatar TomJGooding commented on June 20, 2024 1

I'm sure the maintainers are way ahead of me on this, but posting my findings anyway in case it helps...

The ScrollBar does already release the mouse on a Hide event, but perhaps related is #3460 where what Hide means exactly needs some clarification.

def _on_hide(self, event: events.Hide) -> None:
if self.grabbed:
self.release_mouse()
self.grabbed = None

But more importantly this issue isn't only with scrollbars, but any widget which captures the mouse. For example, if you start a mouse selection with the TextArea which is then hidden, you'll see the same behaviour.

from textual.

davep avatar davep commented on June 20, 2024 1

Digging deeper, what is interesting is the other contents do get a Hide message, which further suggests that the issue here isn't that Hide isn't getting posted, it's that a scrollbar isn't taken into account when sending such messages. For example, the problem documented here is fixed with:

diff --git a/src/textual/screen.py b/src/textual/screen.py
index f9674a47..1cee5b11 100644
--- a/src/textual/screen.py
+++ b/src/textual/screen.py
@@ -793,6 +793,8 @@ class Screen(Generic[ScreenResultType], Widget):
 
                 for widget in hidden:
                     widget.post_message(Hide())
+                    if widget.vertical_scrollbar is not None:
+                        widget.vertical_scrollbar.post_message(Hide())
 
                 # We want to send a resize event to widgets that were just added or change since last layout
                 send_resize = shown | resized

while likely not the actual fix to go with, I think it does suggest that it isn't down to a specific event not being posted, it's just that it isn't being posted as widely as it should.

from textual.

willmcgugan avatar willmcgugan commented on June 20, 2024

At a guess, I suspect it is the mouse capture system not "releasing" the mouse, if the scrollbar is made invisible.

Feels like an easy fix.

from textual.

davep avatar davep commented on June 20, 2024

Just to confirm things: I think @TomJGooding has perfectly summed up the issue here. The situation presented with the MRE above won't result in a Hide event being posted, which does feed back into #3460.

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.