I’ve found a bug there. Haven’t solved it yet. For it’s been working correctly, try to keep button’s size and hit box image size equal. And set button’s size manually.
I found a fix for that bug you mentioned. All you need to do is change the BufferPosition calculation to floor the LocalPosition.Y value. The decimal point has no meaning in texture coordinates and it’s giving you the wrong pixel. So it should look like this:
int BufferPosition = (floor(LocalPosition.Y) * ImageWidth) + LocalPosition.X;
With this fix you can have a button size that doesn’t match the texture size.