Next / Previous / Contents / Shipman's homepage

5.7. ScrolledList.__clickHandler(): Event handler for button 1

This method is called when the user clicks mouse button 1 (usually the left button, but left-handers can set it up to be the right-hand button). If the user has provided a callback procedure, we will figure out which line of the listbox the user clicked on, and pass the number of that line to that callback.
    def __clickHandler(self, event):
        """Called when the user clicks on a line in the listbox.

If there is no callback, don't do anything.
        #-- 1
        if  not self.callback:

The event argument holds the screen y-coordinate of the mouse click in its .y attribute. The .nearest() method on the Listbox widget converts this coordinate into a line number.
        #-- 2
        # [ call self.callback(c) where c is the line index
        #   corresponding to event.y ]
        lineNo = self.listbox.nearest(event.y)

So that the listbox will respond to the PageUp and PageDown keys, we move the keyboard focus to the listbox whenever a family is selected.
        #-- 3