Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

GFxUI.GFxClikWidget


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
/**********************************************************************

Filename    :   GFxClikWidget.uc
Content     :   Unreal Scaleform GFx integration

Copyright   :   (c) 2006-2007 Scaleform Corp. All Rights Reserved.

Portions of the integration code is from Epic Games as identified by Perforce annotations.
Copyright 2010 Epic Games, Inc. All rights reserved.

Notes       :

Licensees may use this file in accordance with the valid Scaleform
Commercial License Agreement provided with the software.

This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR ANY PURPOSE.

**********************************************************************/

class GFxClikWidget extends GFxObject;

// Common event data from CLIK components. You can add or remove members from this struct depending on
// which properties you use. If you don't need Target, remove it as storing it performs memory allocation.

struct EventData
{
	var  GFxObject target;
	var  string   type;
	var  int      data;
	var  int      mouseIndex;
	var  int      button;

	var  int      index;
	var  int      lastIndex;
};

delegate EventListener(EventData data);

/** 
 *  Adds an event listener to the EventDispatcher for events on CLIK widgets.  To add an event, pass in the name of the CLIK event, prefaced with "CLIK_" (e.g. 'CLIK_press')
 *  For a full list of valid CLIK events, see EventTypes.as in the CLIK widget source.
 */
function AddEventListener(name type, delegate<EventListener> listener)
{
	local GFxObject o;
	local string TypeString;

	TypeString = GetEventStringFromTypename(type);
	if( TypeString != "" )
	{
		o = Outer.CreateObject("Object");
		SetListener(o,TypeString,listener);
		ASAddEventListener(TypeString,o,TypeString);
	}
}

function RemoveAllEventListeners(string event)
{
	ASRemoveAllEventListeners(event);
}

/** Checks for a "CLIK_" prefix to the name (to avoid name collisions), and returns the string equivalent with the prefix removed.  If prefix isn't found, errors and returns a null string */
private final function string GetEventStringFromTypename(name Typename)
{
 	local string Typestring;
 
 	Typestring = string(Typename);
 	
	// Check for the "CLIK_" prefix on the name, to make sure it's in our "namespace"
 	if( InStr(Typestring, "CLIK_") >= 0 )
 	{
 		return Split(Typestring, "CLIK_", TRUE);
 	}
	else
	{
		`log("Improper CLIK callback name!  All callback names must start with CLIK_ (e.g. 'CLIK_press')");
		return "";
	}
}

private function SetListener(GFxObject o, string member, delegate<EventListener> listener) { ActionScriptSetFunctionOn(o,member); }
private function ASAddEventListener(string type, GFxObject o, string func) { ActionScriptVoid("addEventListener"); }
private function ASRemoveAllEventListeners(string event) { ActionScriptVoid("removeAllEventListeners"); }

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: fr 12-11-2010 00:00:40.000 - Creation time: ti 22-3-2011 19:57:06.511 - Created with UnCodeX