Prev | Current Page 698 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Usually controls implement their event directly with fields such as onMouseDown or similar;
this practice has the tendency to add a lot of new fields and to bloat the control API. Composition may
be the right solution and can aid in maintaining the correct separation of concerns. Because of this, two
classes MouseInteraction and KeyInteraction exist and they are used as a base for platform - specific
implementations.
The MouseInteraction class defines the events: click , down , up , move , enter , and leave .
Their names are very self - explicative because they are associated with a class that represents the
mouse actions alone. The KeyInteraction just defines up and down . They both define a static method
replace() useful to substitute the interaction object with a new one without losing the associated
handlers. The mouse and keyboard activities are strictly bound to the underlying platform that in
this section is referred to as context . Nevertheless, the controls can be declared before being associated
to a context; for this reason it is important to be able to define a generic container to support the
events and to replace it with the context specifically when this is available.


Pages:
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710