Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
One Click entry view how is implemented
- If you use the keyboard to focus an album, a later click on the focused album should bring up the entry view.
- The viewport scrolling behavior should take into account when expanding the entry view manually.
I introduced some work arounds myself, but I think the end result is a little clearer. Basically, the logic of the code is:
- When the mouseclick callback is called for the first time, increment the
click_count byone and add a timeout to the
_expand_and_scroll). Each subsequent call to the mouseclick callback would increment the click_count by one.
- When the
_timeout_expandmethod gets finally called, it haves to check two things: that the clicked album is the currently focused album and that the click_count hasn't went up. If this conditions are met, then we are sure that this is a second/third valid click, so we proceed to show/hide the entry_view.
- Before returning, we make sure to update the currently selected album and clear the click count.
To knock out the keyboard movement issue and the rapidly clicking albums bugs, I had to do a somewhat dirty workaround on the selection changed callback:
if selected is not self.last_selected_album: if not self.click_count: self.last_selected_album = selected else: self.click_count -= 1
I'll explain the inner if-else since it's pretty confusing: the
not self.click_count allows us to detect that the currently selection change was made through the keyboard, and hence we should update the
last_selected_album or else the next click on that album won't know that that click should behave like a "second" click. On the else branch, reducing the
click_count achives to correctly ignore double clicks when they aren't on the same album, and fixes the rapidly clicking albums issues.
Finally, some other things I moved around/deleted/changed:
- I moved the expand & scroll behavior to the expander callback, so it would be available ot either second/third click gestures or manual expansion.