Package menu

Class MacaoTalkController

Inherited from MacaoMenu

          How a Talk Controller Works
          Adding a Talk Controller to Your Page
          Using a Menu to Switch the Controllers

Constructor   Methods

The MacaoTalkController can be added to a page to display Response Talk Items to the user. The user can select one of the Talk Items to be executed. In Talk Items, which are containing an input field, the user can enter text. The text is sent as keyword to the object. See also MacaoTalkItem.

How a Talk Controller Works

A MacaoObject, which wants its Response Talk Items to be displayed by the Talk Controller, needs to register the controller using MacaoObject.addController(). When the object receives Response Talk Items from another object, it forwards them to all registered controllers. The Talk Controller receives the array of MacaoTalkItem objects via the method controllerShowResponseTalkItems(). The controller gets visible. It displays the Talk Items as Menu Items. If the text of the Talk Item contains one of the placeholders %input% or %password%, the Menu Item will display an input field for that placeholder.

When the user clicks on a menu item without input field or the user enters text to an input field and hits enter, the responding Talk Item is send back to the object's method MacaoObject.talkItem(). The Talk Controller gets hidden.

The object executes the Talk Item and displays the text in a bubble. If the text contains the placeholder %password%, no bubble will be shown, because this would betray the password. The Talk Item name and the entered text are send back to the originator object of the Response Talk Items and may cause there the execution of another Talk Item.

Adding a Talk Controller to Your Page

The page optional/controllers/controllers.html contains a Talk Controller and other controllers. You can add this page to a frame in you application. Or you can use the class MacaoTalkController to create your own Talk Controller.

The following example adds a Talk Controller to the page.

// create controller
var controller = new MacaoTalkController("TalkController", 90, 1)

Because the MacaoTalkController is inherited from the class MacaoMenu, you can use the CSS class names for menus to define the style of the displayed Talk Items. See also MacaoMenuItem.

Using a Menu to Switch the Controllers

You can add a MacaoSentenceController, MacaoTalkController and MacaoSteeringController in a common controller page and use a MacaoMenu to switch between the controllers. This is done in the page optional/controllers/controllers.html.

In the menu, which is used to switch the controllers, there needs to be one MacaoMenuItem object for each controller. The Menu Items need to have the same name as the controller objects. The events of the menu items need to be of the type radio item (see MacaoMenu.setActivation()). The menu items need to send a "setVisibility" event to its controllers, to show or hide the controller.

The user can switch the controllers using the menu. The menu must be registered to the Talk Controller using the method setControllerMenu(). So the Talk Controller can select it's own Menu Item, when it receives Talk Items for display.

The following example adds a Talk Controller to the page and a menu, which is used to switch between the controllers. The creation of the other controllers is not shown here.

var menuItem

// create talk controller
var talkController = new MacaoTalkController("TalkController", 90, 1)

// set the menu, which controls the visibility
talkController.setControllerMenu("ControllerMenu")

// define the controller, which is shown
// when the talk controller is hidden
talkController.setDefaultControllerMenuItem("SentenceController")

	
// create the controller menu
var controllerMenu = new MacaoMenu("ControllerMenu", null, 1, 5)


// add menu item SentenceController
menuItem = new MacaoMenuItem(
	"SentenceController", "Actions",
	"optional/controllers/handsmall.gif", null, null,
	"setVisibility", null, "SentenceController"
)
// set menu item as radio item
menuItem.setActivation(true, true)
// add item to menu
controllerMenu.addMenuItem(menuItem)

	
// add menu item SteeringController
menuItem = new MacaoMenuItem(
	"SteeringController", "Steering",
	"optional/controllers/steeringsmall.gif", null, null,
	"setVisibility", null, "SteeringController"
)
menuItem.setActivation(true, true)
controllerMenu.addMenuItem(menuItem)

	
// add menu item TalkController
menuItem = new MacaoMenuItem(
	"TalkController", "Answer a sentence",
	"optional/controllers/bubblesmall.gif", null, null,
	"setVisibility", null, "TalkController"
)
// set the Talk Controller hidden,
// until the first response talk items are sent
menuItem.setVisibility(false)
menuItem.setActivation(true, true)
controllerMenu.addMenuItem(menuItem)
Constructor Summary
MacaoTalkController(String name, integer left, integer top)
     Use this constructor to create a new Talk Controller on a page.

Method Summary
void setControllerMenu(String menuObjectName, String defaultMenuItemName)
     Call this method to link the controller to a controller menu.
void setDefaultControllerMenuItem(String defaultMenuItemName)
     Call this method to set the controller, which is shown, when the Talk Controller is hidden.

Inherited Methods
addMenuItem, getCssClassName, getMenuItem, initMenu, removeAllMenuItems, setFocusToInput, setMenuCharacteristics, setMenuItemActive, setMenuItemImageSource, setMenuItemVisibilityactivateDrag, activateDrop, addController, broadcastEvent, createLayer, createLook, displayMeasures, getActualLook, getCollisionCheck, getCssClassName, getFrameName, getHeight, getLayer, getLeft, getLook, getName, getTitle, getTop, getType, getVisibility, getWidth, getZIndex, getZoom, hasLook, initObject, isController, isDragActive, isDragged, isDropActive, isDropAllowed, moveTo, moveToCenter, notifyControllers, onClick, onClickOther, onClickOtherItem, onClickWindow, onCollisionOut, onCollisionOver, onDblClick, onDblClickOther, onDblClickWindow, onDragEnd, onDragOut, onDragOver, onDragStart, onDrop, onKeyDown, onKeyPress, onKeyUp, onLoad, onMouseDown, onMouseDownWindow, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onMouseUpWindow, onUnload, openPage, postEvent, refreshZoom, removeController, removeObject, say, scrollVisible, sendEvent, setActualLook, setBaseSize, setCollisionCheck, setCssClassName, setForwardMouseEvents, setHTML, setImage, setScrollVisibleOptions, setTitle, setToolTip, setType, setVisibility, setZIndex, setZoom, toBack, toFront

Constructor Details
MacaoTalkController(String name, integer left, integer top)

Method Details
void setControllerMenu(String menuObjectName, String defaultMenuItemName)

void setDefaultControllerMenuItem(String defaultMenuItemName)