Beispiel #1
0
 @Override
 public boolean onMouseClicked(int posX, int posY, int mouseButtonIndex, boolean overlap) {
   super.onMouseClicked(posX, posY, mouseButtonIndex, overlap);
   boolean clickedOnGrid =
       !overlap && Geometry.isDotInArea(getX(), getY(), this.width, this.height, posX, posY);
   if (clickedOnGrid) {
     handleMouseClickGrid(posX, posY);
   }
   return clickedOnGrid;
 }
Beispiel #2
0
 protected void handleMouseClickGrid(int mouseX, int mouseY) {
   for (int i = 0; i < content.size(); i++) {
     GridEntry entry = content.get(i);
     int slotPosX = getX() + (i % xSlots) * slotWidth;
     int slotPosY = getY() + (i / xSlots) * slotHeight;
     int slotWidth = this.width;
     int slotHeight = this.slotHeight;
     boolean clickedOnEntry =
         Geometry.isDotInArea(slotPosX, slotPosY, slotWidth, slotHeight, mouseX, mouseY);
     if (clickedOnEntry) entry.onClick(this, mouseX, mouseY);
   }
 }