Esempio n. 1
0
	virtual void ProcessEvent( Event &event ) {
		Element *elem = event.GetTargetElement();

		UI_ScriptDocument *document = dynamic_cast<UI_ScriptDocument *>( elem->GetOwnerDocument() );
		if( !document || document->IsLoading() ) {
			return;
		}

		if( UI_Main::Get()->debugOn() ) {
			Com_Printf( "ScriptEventCaller: Event %s, target %s, func %s\n",
						event.GetType().CString(),
						event.GetTargetElement()->GetTagName().CString(),
						funcPtr.getName() );
		}

		if( funcPtr.isValid() ) {
			event.AddReference();
			try {
				asIScriptContext *context = as->getContext();

				// the context may actually be NULL after AS shutdown
				if( context ) {
					funcPtr.setContext( context );
					funcPtr( NULL, &event );
				}
			} catch( ASBind::Exception & ) {
				Com_Printf( S_COLOR_RED "ScriptEventListener: Failed to call function %s\n", funcPtr.getName() );
			}
		} else {
			Com_Printf( S_COLOR_RED "ScriptEventListener: Not gonna call invalid function %s\n", funcPtr.getName() );
		}
	}
Esempio n. 2
0
	virtual void ProcessEvent( Event &event )
	{
		// onloads cant be called within building process
		if( /* event.GetType() == "load" && */ asmodule->isBuilding() )
		{
			UI_Main::Get()->getDocumentLoader()->postponeOnload( this, event );
			return;
		}

		Element *elem = event.GetTargetElement();

		if( UI_Main::Get()->debugOn() ) {
			Com_Printf( "ScriptEventCaller: Event %s, target %s, func %s\n",
				event.GetType().CString(),
				event.GetTargetElement()->GetTagName().CString(),
				funcPtr.getName() );
		}

		if( funcPtr.isValid() ) {
			elem->AddReference();
			event.AddReference();
			try {
				asIScriptContext *context = asmodule->getContext();

				// the context may actually be NULL after AS shutdown
				if( context ) {
					funcPtr.setContext( context );
					funcPtr( elem, &event );
				}
			} catch( ASBind::Exception & ) {
				Com_Printf( S_COLOR_RED "ScriptEventListener: Failed to call function %s\n", funcPtr.getName() );
			}
		}
		else {
			Com_Printf( S_COLOR_RED "ScriptEventListener: Not gonna call invalid function %s\n", funcPtr.getName() );
		}
	}