I use onions to add a sweeter taste to some dishes, for example in tomato sauce for pasta. I cook them in oil, with some salt, before adding the other ingredients. It seems to me that when I turn the temperature too hot, the onions don't become sweet at all, but rather retain some of their spiciness. They also look less "glassy". Why is this?
Well, you're definitely right. Onions cooked at a high temperature act differently than ones cooked at a low temperature, per "the bible" aka On Food and Cooking. However, it doesn't go in to much of an explanation as to why. Probably the most relevant aspects of what is in there are:
Since a low temperature produces less volatiles, I assume that the natural sugars of the onion shine through instead.
It's probably also important to understand where the oniony flavor comes from. The spice, as you describe it, is the onions natural defense mechanism. However, it doesn't exist defacto in the onion, but is rather the result of a chemical reaction. The onion stores very reactive sulfur in the cell fluid, and a seperate trigger mechanism in a storage vacuole. When you cut / crush / cook/ peel the onion, you break the vacuole and the enzyme and sulfur cause a chemical reaction giving off the spice. (p272 & 310)