keyCode 13 is the Enter key. So, in your controller, you can do this:
this.addObserver(this.getContextElement(), "onkeyup", "EnterKey");
this.addObserver(this.getCommand("EnterKey"), "onResponse",
"MyCustomCommand", { } );
As you can see above, we're observing the EnterKey behavior for when
onResponse fires and then executing your "MyCustomCommand".
Hope this clears up some things about chaining and observing commands,
Jaime Bueza
this.addCommand("EnterKey", "stdlib.behavior.EnterKeyBehavior");
Correct?
http://blastmojo.com/docs/files/controller/Controller-js.html#Controller.addCommand
the whole "addCommands: function()" block gets invoked when the
current Controller gets mapped (when the application gets
boostrapped). This should really be drawn out, but I'll give it a
shot:
1) Browser interprets SiteMap.js
2) Iterate through each item in the SiteMap and map controllers
according to their specified context
3) When instantiating a Controller, we add specific Commands that the
Controller will be using (addCommands())
4) After adding commands to the Controller, we apply its business
logic (addObservers() + addIntercepts())
5) After all Controllers are mapped, the application is ready for the
User to interact with the application
Diving deeper into the architecture of Mojo, the relationship between
commands/behaviors (behaviors are just commands except they are
defined by manipulating the UI instead of consuming a data provider)
and controllers are:
1) Controllers can use multiple Commands (Command, Behavior, Rule --
These are all types of Commands)
2) Commands can be associated to multiple Controllers (By parameterization)
3) Controllers and Commands are reusable in that everything can be
parameterized (FilmStripController, TweenBehavior,
GenericServiceCommand)
Going back to the example I wrote and clarifying on the point of
chaining or observing command instances, "EnterKey" is just a
reference as I believe that Controllers have a Hash map of all
commands in its registry. You could actually name it anything you
want:
this.addCommand("HelloThereBehavior", "stdlib.behavior.EnterKeyBehavior");
and then reference it in:
this.addObserver(this.getContextElement, "onkeyup", "HelloThereBehavior");
Hope this helps,
Jaime
PS: I think I'm going to get yelled at for saying "registry" in this
email, as that's a very Windows-like term, but provides the best
illustration of the idea.