One Click entry view how is implemented

fossfreedom edited this page Jan 2, 2013 · 1 revision
  • 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:

  1. When the mouseclick callback is called for the first time, increment the click_count by one and add a timeout to the _timeout_expand method (old _expand_and_scroll). Each subsequent call to the mouseclick callback would increment the click_count by one.
  2. When the _timeout_expand method 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.
  3. 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[0] is not self.last_selected_album:
    if not self.click_count:
        self.last_selected_album = selected[0]
    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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.