global agent method

Share business templates, ideas, experiences, etc with fellow Servoy developers here

global agent method

Postby Cain » Sun Nov 21, 2004 6:55 pm

My current client is very excited about the agent, especially as they are on a hiring spree and dealing with training new people to use a new system.

I've created a global method that captures the current form and element, then looks to a table called 'agent_script' for agent positioning, baloon size and location.

The idea here, is to set this as the onFocusGained method (or first step of another onFocusGained method) of the elements on a form. With the agent active, as the user goes from element to element, the bird gives context-specific help.

I initially was creating a method for each field, so this will save me some time, but also I plan to open this up to the user interface, and allow the client administrator to edit the help text.

Thought I'd share this here, in case it might save someone else a bit of work. Of course, I'm also open to input and/or improvements!

//
// This method will check for agent messages for the current form and element. If none,
// the agent's location and balloon size will be reset.
//
globals.formCurrent = currentcontroller.getName(); //capture the form name
if ( application.getMethodTriggerElementName() ) //if specified trigger element, set; else 'unknown'
{
globals.elementCurrent = application.getMethodTriggerElementName();
}
else
{
globals.elementCurrent = 'unknown';
}
// if specified, set the balloon size for the agent, otherwise set to default.
if ( forms[currentcontroller.getName()].global_current_agent_script.size_x && forms[currentcontroller.getName()].global_current_agent_script.size_y )
{
plugins.agent.setBalloonSize(forms[currentcontroller.getName()].global_current_agent_script.size_x, forms[currentcontroller.getName()].global_current_agent_script.size_y );
}
else
{
plugins.agent.setBalloonSize(200,100);
}
// if specified, set location of agent, otherwise set to either upper left of element, or in lower right-hand corner.
if ( forms[currentcontroller.getName()].global_current_agent_script.loc_x && forms[currentcontroller.getName()].global_current_agent_script.loc_y )
{
plugins.agent.setLocation(forms[currentcontroller.getName()].global_current_agent_script.loc_x, forms[currentcontroller.getName()].global_current_agent_script.loc_y );
}
else
{
//if specific element and msg, use position, else, lower right
if (application.getMethodTriggerElementName() && forms[currentcontroller.getName()].global_current_agent_script.msg_text)
{
var locx = forms [currentcontroller.getName()].elements[application.getMethodTriggerElementName()].getLocationX();
var locy = forms [currentcontroller.getName()].elements[application.getMethodTriggerElementName()].getLocationY();
var elewidth = forms [currentcontroller.getName()].elements[application.getMethodTriggerElementName()].getWidth();
plugins.agent.setLocation(locx + elewidth + 50 , locy );
}
else
{
plugins.agent.setLocation(application.getWindowWidth()- 200, application.getWindowHeight()- 200);
} }
// If there's a message, speak it.
if ( forms[currentcontroller.getName()].global_current_agent_script.msg_text )
{
plugins.agent.speak(forms[currentcontroller.getName()].global_current_agent_script.msg_text);
}
Cain
 

Update

Postby Cain » Sun Nov 21, 2004 8:34 pm

I took out the portion that sets the position based on the location of the triggering element.

I found that the code doesn't account for the width of the controller, the position of the window, or the fact that the element may be inside a tab panel and therefore not a valid element for this form.

It was nice on a simple form to have the bird go just above and to the right of the field in question, but I can do without that.

If anyone can solve those issues and put that feature back into the code, I'd be interested, though.
Cain
 

Postby Westy » Wed Sep 07, 2005 11:08 pm

I did a search on "Agent", but did not find many posts. Is anyone still using the Agent? When I attempt to use it, the words appear in the balloon beside the Parrot, but there is no sound. How can I make the agent speak? I am using Windows XP Professional.
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA


Return to Sharing Central

Who is online

Users browsing this forum: No registered users and 8 guests

cron