Pregunta

DivElement collectWoodHover = querySelector("#collectWood");

if (collectWoodHover.onMouseOver == true) {
  querySelector("#collectWoodHover").style.display = "block";
} else {
  querySelector("#collectWoodHover").style.display = "none";
}

Hello!

I was flicking through some of the stuff in the auto complete thing in Dart and found .onMouseOver.
I wonder if I am using it correctly because it doesn't seem to work. The div element is always hidden.

Thanks for your help in advance.

¿Fue útil?

Solución

Try something like:

collectWoodHover.onMouseOver.listen( (event) {
  print('onMouseOver!');
} );

onMouseOver is a stream. You can find more information how to use streams in Dart here.

Otros consejos

onMouseOver is an event stream. You use it like:

DivElement collectWoodHover = querySelector("#collectWood");

collectWoodHover.onMouseOver.listen((e) => 
  e.target.style.display = "block";
} 

collectWoodHover.onMouseOut.listen((e) => 
  e.target.style.display = "none";
} 

I have not actually tried this code. But you should get the idea.

I think you are not selecting the div correctly.

Try:

querySelector(collectWoodHover).style.display = "block";

Because it's a var as in sample, or:

querySelector("#onHover").style.display = "block"; 

if the div id is 'onHover' that should work

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top