On Fri, Mar 18, 2011 at 09:01, Benjamin Dreux <[email protected]>wrote:
> As Derrell asked here is the description of what i understood about
> the FiniteStateMachine.eventListener() method.
>
> According to the mouse haze exemple. When we want to run an event on
> the FSM. Here is a part of the code that make me think this way :
>
> // Dispatch an event to cause us to continue.
> var event = new qx.event.type.Event();
> event.setType("KickInTheAss");
> _this.eventListener(event);
>
> As i understand it. FSM doesn't use a classic .addListener() the
> change it's state.
> It look like i'm wrong...
>
>
>
> What I'm trying to do is to change the fsm state according to some button
> push.
> Here is what I did to match the button push event to the fsm event:
>
> this.getObject("addButton").addListener("execute",function(){
> var e = new qx.event.type.Event();
> e.setType("add");
> this.eventListener(e);
> },this);
>
> This beeing my FSM.
>
> Is there a better way to accomplish what i want ??
>
The "events" map in the stateInfo parameter to the State constructor
contains the mapping from an event on a particular object, to a transition.
For example, you might have something like this in your stateInfo map:
"events" :
{
"execute" :
{
// Identification configuration is saved
"identification_save" :
"Transition_Idle_to_AwaitRpcResult_via_identification_save",
// Access configuration is saved
"access_save" :
"Transition_Idle_to_AwaitRpcResult_via_access_save",
// Network configuration is saved
"network_save" :
"Transition_Idle_to_AwaitRpcResult_via_network_save",
// Email configuration is saved
"email_save" :
"Transition_Idle_to_AwaitRpcResult_via_email_save",
// Email configuration is saved, and a test message is requested
"email_save_send_test_message" :
"Transition_Idle_to_AwaitRpcResult_via_email_save"
},
// Request to call some remote procedure call which is specified
by
// the event data.
"callRpc" :
"Transition_Idle_to_AwaitRpcResult_via_generic_rpc_call",
// When we get an appear event, retrieve the current configuration
"appear" :
{
"main.canvas" :
"Transition_Idle_to_AwaitRpcResult_via_appear"
},
In this example, "identification_save" is the friendly name of a button on
which an execute event might occur, and when that event does occur, the
transition "Transition_Idle_to_AwaitRpcResult_via_identification_save"
should be processed.
That button is set up something like this:
o = new qx.ui.form.Button("Save");
fsm.addObject("identification_save", o);
// Create event listener to dispatch event to finite state machine.
o.addListener(
"execute",
function(e)
{
// Send an event to the finite state machine
fsm.fireImmediateEvent("execute", this);
});
If you don't need for the event to be immediate, you could also simply add
fsm.eventListener to the button's execute event:
o.addListener("execute", fsm.eventListener, this);
I *really* need to produce an example of using this stuff, that I can
distribute, that shows standard usage in a normal GUI environment. My mouse
maze example was fun, but is not sufficiently similar to normal usage. Since
I'm currently working on a project that will be open-source, and will likely
use the FSM in that project, maybe it will serve as a better example. In the
mean time, I'll try to answer questions as they arise.
Cheers,
Derrell
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel