I have a mutlifunctional interface and one of the functions requires the modifying of the default ScreenSpaceEventHandle for the click input action.
but once the user goes about to other functions, my handler is still active!
and runs its own function.
I need to set it back to default, meaning the expected feel of mouse movement and infobox popping up when clicking on polygons.
So my functions is called Aggregate and inside it I have :
var scene = viewer.scene;
var handler = viewer.screenSpaceEventHandler;
handler.setInputAction(function(click) {
pickedObject = scene.pick(click.position); //console.log ("picked "+ pickedObject.id.properties.bui_id);
if(Cesium.defined(pickedObject)) {
highlightedEntity = pickedObject.id;
var highlight = highlightedEntity.polygon.material= Cesium.Color.GREEN;
...... more things to do here....
},Cesium.ScreenSpaceEventType.LEFT_CLICK);
Once I call another function, this handler is still active!
Been a bit since I’ve played with Cesium input handling - does it only allow you to add one listener per event type per ScreenSpaceEventHandler instance? I’ve gotten a bit more used to DOM APIs and such that let you register multiple listeners for events, so you need to pass the exact same function reference to unregister it.
The way we handle it in Cesium is just to store the listener in a dictionary with the specified action as the key (See Source/Core/ScreenSpaceEventHandler.js#L704). So you get the benefit of not having to keep track of the function reference, but you only can register the one function. We could potentially map a list of functions rather than the one function to each action, but I haven’t seen any requests to do so. Feel free to open a feature request if you see that being a big pain point!
I have one more question,
I have used the removeInputAction, but then I also want the infobox to appear as in the default case.
I believe I'd have to setInputAction again, right? but this time give it the function to call infobox?