int (Point point) { if (point.x < myPadding.left || point.y < myPadding.top) return -1; int x = xVisibleToGrid(point.x), y = yVisibleToGrid(point.y); if (x >= myItemsPerRow || point.x > xGridToVisible(x) + myCellSize.width || point.y > yGridToVisible(y) + myCellSize.height) { return -1; } int index = myItemsPerRow * y + x; return index >= 0 && index < myCategory.getEmoji().size() ? index : -1; }