Skip to content

Commit

Permalink
Pass KeyEvent that caused accelerator event to fire in the accelerato…
Browse files Browse the repository at this point in the history
…r event.
  • Loading branch information
danielperano committed Feb 13, 2024
1 parent 79c7baa commit 6709504
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@

public class AcceleratorEvent extends InputEvent {

protected final KeyEvent cause;
protected final Key[] keys;

public AcceleratorEvent(InputManager manager, Key[] keys){
public AcceleratorEvent(InputManager manager, KeyEvent cause, Key[] keys){
super(manager);
this.cause = cause;
this.keys = keys;
}

public KeyEvent getCause(){
return cause;
}

public Key[] getKeys(){
return keys;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public ValueProperty<Consumer<Throwable>> uncaughtThrowableHandler(){

public void addAccelerator(Consumer<AcceleratorEvent> listener, Key... keys){
Consumer<KeyEvent> handler = (evt) -> {
listener.accept(new AcceleratorEvent(evt.getManager(), keys));
listener.accept(new AcceleratorEvent(evt.getManager(), evt, keys));
};
accelerators.add(new Accelerator(keys, handler));
dispatcher.subscribe(KeyEvent.class, EventFilters.accelerator(keys), handler);
Expand Down

0 comments on commit 6709504

Please sign in to comment.