aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/handlers/InputHandlers.java
blob: d0a8812900d21a06fcb856f0f06699f1ae5f7536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package jcgp.gui.handlers;

import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;
import jcgp.gui.population.GUIGene.GUIGeneState;
import jcgp.gui.population.GUIInput;

public final class InputHandlers {

	private static EventHandler<MouseEvent> mouseEnteredHandler = new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			//((GUIGene) event.getSource()).mouseEnter();
			((GUIInput) event.getSource()).setState(GUIGeneState.HOVER);
		}
	};
	
	private static EventHandler<MouseEvent> mouseExitedHandler = new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			//((GUIGene) event.getSource()).mouseExit();
			((GUIInput) event.getSource()).setState(GUIGeneState.NEUTRAL);
		}
	};
	
	public static void addHandlers(GUIInput input) {
		input.addEventHandler(MouseEvent.MOUSE_ENTERED, mouseEnteredHandler);
		input.addEventHandler(MouseEvent.MOUSE_EXITED, mouseExitedHandler);
	}
	
}