Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 Francy Callbacks
 2.1 Categories
 2.2 Families
 2.3 Representations
 2.4 Operations
 2.5 Globals
 2.6 Attributes

2 Francy Callbacks

Callbacks are objects holding a Function, a list of arguments and a trigger event. Callbacks are used to execute GAP code from a remote client using the Trigger Operation.

Callbacks can be added directly to Menus and Shapes.

Please see Francy-JS for client implementation.

2.1 Categories

In this section we show all Francy Callback Categories.

2.1-1 IsCallback
‣ IsCallback( arg )( filter )

Returns: true or false

Identifies Callback objects.

2.1-2 IsRequiredArg
‣ IsRequiredArg( arg )( filter )

Returns: true or false

Identifies RequiredArg objects.

2.1-3 IsArgType
‣ IsArgType( arg )( filter )

Returns: true or false

Identifies ArgType objects.

2.1-4 IsTriggerType
‣ IsTriggerType( arg )( filter )

Returns: true or false

Identifies TriggerType objects.

2.2 Families

In this section we show all Francy Callback Families.

2.3 Representations

In this section we show all Francy Callback Representations.

2.3-1 IsCallbackRep
‣ IsCallbackRep( arg )( filter )

Returns: true or false

Checks whether an Object has a Callback internal representation.

2.3-2 IsRequiredArgRep
‣ IsRequiredArgRep( arg )( filter )

Returns: true or false

Checks whether an Object has a RequiredArg internal representation.

2.3-3 IsArgTypeRep
‣ IsArgTypeRep( arg )( filter )

Returns: true or false

Checks whether an Object has a ArgType internal representation.

2.3-4 IsTriggerTypeRep
‣ IsTriggerTypeRep( arg )( filter )

Returns: true or false

Checks whether an Object has a TriggerType internal representation.

2.4 Operations

In this section we show all Francy Callback Operations.

2.4-1 Callback
‣ Callback( IsTriggerType, IsFunction, IsList(object) )( operation )

Returns: Callback

Creates a Callback object that holds a Function and the RequiredArgs to be executed by a TriggerType.

Please note, the Function must always Return

Examples:

Create a simple Callback with no arguments:

gap> MyFunction := function() return "Hello World!"; end;
gap> callback := Callback(MyFunction);
gap> Id(callback);

Create a Callback with one required argument of type string:

gap> MyFunction := function(str) return Concatenation("Hello", " ", str); end;
gap> callback := Callback(MyFunction);
gap> arg := RequiredArg(ArgType.STRING, "Your Name");
gap> Add(callback, arg);

Create a Callback with one known argument of type string:

gap> MyFunction := function(args) return args; end;
gap> callback := Callback(MyFunction, ["Hello World"]);

Create a Callback with one known argument and one required argument of type string:

gap> MyFunction := function(a,b) return Concatenation(a, b); end;
gap> callback := Callback(MyFunction, ["Hello "]);
gap> arg := RequiredArg(ArgType.STRING, "Your Name");
gap> Add(callback, arg);

Create a Callback with one known argument and one required argument of type string and double click trigger Type:

gap> MyFunction := function(a,b) return Concatenation(a, b); end;
gap> callback := Callback(TriggerType.DOUBLE_CLICK, MyFunction, ["Hello "]);
gap> arg := RequiredArg(ArgType.STRING, "Your Name");
gap> Add(callback, arg);

In order to see the output of the previous examples, we have to simulate the external call to Trigger operation:

gap> MyFunction := function(a,b) return Concatenation(a, b); end;
gap> callback := Callback(TriggerType.DOUBLE_CLICK, MyFunction, ["Hello "]);
gap> arg := RequiredArg(ArgType.STRING, "Your Name");
gap> SetTitle(arg, "Enter your name");
gap> Title(arg);
gap> Add(callback, arg);
gap> SetValue(arg, "Manuel"); # simulate the user input
gap> Value(arg);
gap> Trigger(GapToJsonString(Sanitize(callback))); # simulate the external trigger

Create a Noop Callback, useful for Menu holders, where no Function is required:

gap> callback := NoopCallback();

2.4-2 NoopCallback
‣ NoopCallback( )( operation )

Returns: Callback

Creates an empty Callback object that does nothing. Useful to create menu holders.

2.4-3 RequiredArg
‣ RequiredArg( IsArgType, IsString(title) )( operation )

Returns: RequiredArg

Creates a Callback with a RequiredArg. RequiredArg is user input driven and required for the execution of a Callback Function. The value for this argument will be provided by the user.

2.4-4 Trigger
‣ Trigger( IsString(JSON) )( operation )

Returns: the result of the execution of the Callback defined Function

Triggers a Callback Function in GAP. Gets a JSON String object representation of the callback to execute.

2.4-5 Add
‣ Add( IsCallback[, IsRequiredArg, List(IsRequiredArg)] )( operation )

Returns: Callback

Adds a RequiredArg to a specific Callback.

2.4-6 Remove
‣ Remove( IsCallback[, IsRequiredArg, List(IsRequiredArg)] )( operation )

Returns: Callback

Removes a RequiredArg from a specific Callback.

2.5 Globals

In this section we show the Global Callback Francy Records for multi purpose.

2.6 Attributes

In this section we show the Francy Callback Attributes

2.6-1 Title
‣ Title( arg )( attribute )

Returns: IsString with the title of the object

A title on a RequiredArg is used to retrieve input from a user.

2.6-2 Title
‣ Title( arg1 )( operation )

2.6-3 SetTitle
‣ SetTitle( IsRequiredArg, IsString )( operation )

Sets the title of the RequiredArg.

2.6-4 Value
‣ Value( arg )( attribute )

Returns: IsString with the value of the object

A value on a RequiredArg is the actual input value to be passed to back gap from the client GUI. These values are stored as String for convenience, even if the ArgType specified for the RequiredArg is of another type. Hence, explicit conversion is required within the Callback Function.

2.6-5 Value
‣ Value( arg1 )( operation )

2.6-6 SetValue
‣ SetValue( IsRequiredArg, IsString )( operation )

Sets the value of the RequiredArg.

2.6-7 ConfirmMessage
‣ ConfirmMessage( arg )( attribute )

Returns: a IsString with the message to be shown to the user before the Callback execution.

This will display a confirmation message before any Callback is executed.

2.6-8 ConfirmMessage
‣ ConfirmMessage( arg1 )( operation )

2.6-9 SetConfirmMessage
‣ SetConfirmMessage( IsRequiredArg, IsString )( operation )

Sets the value of the confirmation message to display to the user.

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 Ind

generated by GAPDoc2HTML