예제 #1
0
 public boolean mouseMoved(InputEvent event, float x, float y) {
   stageToLocalCoordinates(Vector2.tmp);
   x = Vector2.tmp.x;
   y = Vector2.tmp.y;
   if (x > 0 && x < getWidth() && y > 0 && y < getHeight()) {
     listSelectedIndex =
         (int) ((getHeight() - style.listBackground.getTopHeight() - y) / itemHeight);
     listSelectedIndex = Math.max(0, listSelectedIndex);
     listSelectedIndex = Math.min(items.length - 1, listSelectedIndex);
   }
   return true;
 }
예제 #2
0
 public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
   if (pointer == 0 && button != 0) return false;
   stageToLocalCoordinates(Vector2.tmp);
   x = Vector2.tmp.x;
   y = Vector2.tmp.y;
   if (x > 0 && x < getWidth() && y > 0 && y < getHeight()) {
     listSelectedIndex = (int) ((getHeight() - y) / itemHeight);
     listSelectedIndex = Math.max(0, listSelectedIndex);
     listSelectedIndex = Math.min(items.length - 1, listSelectedIndex);
     selectedIndex = listSelectedIndex;
     if (items.length > 0) {
       ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
       SelectBox.this.fire(changeEvent);
       Pools.free(changeEvent);
     }
   }
   return true;
 }