You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
511 B
30 lines
511 B
package mightypork.gamecore.gui.components;
|
|
|
|
|
|
import mightypork.gamecore.control.events.MouseButtonEvent;
|
|
|
|
|
|
public abstract class ClickableComponent extends InputComponent {
|
|
|
|
private boolean btnDownOver;
|
|
|
|
|
|
@Override
|
|
public void receive(MouseButtonEvent event)
|
|
{
|
|
if (!event.isButtonEvent()) return;
|
|
|
|
if (event.isDown()) {
|
|
btnDownOver = event.isOver(this);
|
|
}
|
|
|
|
if (event.isUp()) {
|
|
|
|
if (btnDownOver && event.isOver(this)) {
|
|
triggerAction();
|
|
}
|
|
|
|
btnDownOver = false;
|
|
}
|
|
}
|
|
}
|
|
|