kivy-garden / garden.matplotlib

Matplotlib backends using kivy
MIT License
104 stars 50 forks source link

graph doesn't register events if the size of the graph is greater than the window #71

Open jennm opened 3 years ago

jennm commented 3 years ago

If a graph is made to be larger than the size of the window, then each point within the graph isn't reliably registered to be within the graph. If the portion of the screen visible to the user is such that the bottom left corner's coordinates are (0, 0), the graph works as expected, if it is not, sometimes the point is registered to be within the graph and other times it is not. This issue can be corrected by modifying the _to_widget function within the FigureCanvasKivy class so that instead of recursively going to the parent widget until the "initial" widget is reached, we stop at the parent of the current widget. This corrects the issue because in some circumstances going to the "initial" widget causes the y position of the cursor to be modified incorrectly. Stopping at the parent of the current widget prevents this modification from occurring incorrectly.

Adding this function should correct this issue. def _to_widget(self, x, y, relative=False):

    if self.parent:
        return self.parent.to_local(x, y, relative=relative)
    return self.to_local(x, y, relative=relative)

I've made these changes on my local copy, but I'm not sure how to proceed in making these changes on github.