Closed Updownquark closed 11 years ago
Stateful styles work, but they need a little more work. For example, if the button test is changed to put the style.hover attribute before style.clicked, the hover takes precedence and the button doesn't change in response to click. Hover should be a lower priority style somehow.
Also, the button seems to be repainted on mouse move--looks like mouse entered events are getting fired on mouse move. And when the mouse leaves the whole browser, the button stays yellow.
As to the difficult problem that needed pondering above, I decided to go the simple route. The element style, the self style, the heir style, and all the group styles are stateful and the precedence for an element's display is self>element>groups>parent heir>parent. So if a stateful style attribute is set on the element style and an attribute in the self style conflicts with it, the self style will take precedence.
I believe this is done well enough to close.
Implement the concept of a state in a MuisElement. A state is something liked "focused" or "clicked" or "hovered" that may be used to control the appearance or behavior of that element.
The state engine should have a listener engine and styles should be hooked into the state engine such that a notation like
style.clicked="bg.color=green"
is accepted from the XML and the concept is easily accessed from code.We need to find firm standards for the
style.xxx
notations. For example, if a style attribute is specified in both the self style and the clicked style, which takes precedence when the element is clicked? If the self style, should we have a notion ofstyle.default
or similar to allow specification of styles for a particular element under the stateful styles? If clicked style, we probably need an overriding self style that is active regardless of the state. This is a difficult problem. Needs pondering.