Skip to content

Commit

Permalink
wrap event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Oct 25, 2024
1 parent 2a99cf9 commit 6a3bb0e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.github.xpenatan.gdx.backends.teavm.dom.DocumentWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.EventListenerWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.EventWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.LocationWrapper;
import com.github.xpenatan.gdx.backends.teavm.dom.WindowWrapper;
import org.teavm.jso.browser.AnimationFrameCallback;
import org.teavm.jso.browser.Location;
import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener;

/**
Expand Down Expand Up @@ -64,7 +66,11 @@ public int getClientHeight() {

@Override
public void addEventListener(String type, EventListenerWrapper listener) {
EventListener<?> eListener = (EventListener<?>)listener;
window.addEventListener(type, eListener);
window.addEventListener(type, new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
listener.handleEvent((EventWrapper)evt);
}
});
}
}

0 comments on commit 6a3bb0e

Please sign in to comment.