void UI_ScriptDocument::ProcessEvent( Rocket::Core::Event &event ) { if( event.GetType() == "afterLoad" && event.GetTargetElement() == this ) { if( module ) { owner = event.GetParameter<void *>( "owner", NULL ); as->finishBuilding( module ); as->setModuleUserData( module, owner ); } isLoading = false; // handle postponed onload events (HOWTO handle these in cached documents?) for( PostponedList::iterator it = onloads.begin(); it != onloads.end(); ++it ) { Rocket::Core::Event *load = *it; this->DispatchEvent( load->GetType(), *(load->GetParameters()), true ); load->RemoveReference(); } // and clear the events onloads.clear(); return; } if( event.GetType() == "beforeUnload" && event.GetTargetElement() == this ) { if( module ) { // FIXME: destroy script event listeners here somehow! // destroy the AS module by name to prevent crashes in case multiple document instances share the same module pointer as->buildReset( GetSourceURL().CString() ); module = NULL; } return; } if( isLoading ) { Rocket::Core::Event *instanced = Rocket::Core::Factory::InstanceEvent( event.GetTargetElement(), event.GetType(), *event.GetParameters(), true ); onloads.push_back( instanced ); event.StopPropagation(); return; } Rocket::Core::ElementDocument::ProcessEvent( event ); }
void FormSignalListener::ProcessEvent(Rocket::Core::Event& event) { const Rocket::Core::Dictionary *d = event.GetParameters(); UISignalData *data = new UISignalData(); Rocket::Core::String s; Rocket::Core::Variant *v; int n; while (d->Iterate(n, s, v)) { Rocket::Core::String val = v->Get<Rocket::Core::String>(); data->set(string(s.CString()), string(val.CString())); } PyScripting::getInstance()->broadcast(signal_name,{data}, true, true); }
void Console::ProcessEvent(Rocket::Core::Event& event) { String controlId(event.GetCurrentElement()->GetId().CString()); if (controlId == "cmd") { int key = event.GetParameters()->Get<int>("key_identifier", 0); Rocket::Controls::ElementFormControl* inputBox = static_cast<Rocket::Controls::ElementFormControl*>(event.GetCurrentElement()); if (key == Rocket::Core::Input::KI_RETURN) { String command = inputBox->GetValue().CString(); inputBox->SetValue(""); Execute(command); } } }
void RocketMenuPlugin::ProcessEvent(Rocket::Core::Event& event) { Rocket::Core::Element *element = event.GetCurrentElement(); if (event.GetType() == "click") { if (element->GetTagName() == "ftr") { SetNextItemValue(element->GetParentNode()->GetParentNode()); event.StopPropagation(); } else if (element->GetTagName() == "hdr") { SetPreviousItemValue(element->GetParentNode()->GetParentNode()); event.StopPropagation(); } else { DoItemAction(ItemActionEnter, element); } } else if (event.GetType() == "mousemove") { if (element->GetTagName() == "div") { HighlightItem(element); } else if (element->GetTagName() == "key1") { Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode(); SetActiveKeySlot(menu_item, 0); } else if (element->GetTagName() == "key2") { Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode(); SetActiveKeySlot(menu_item, 1); } } else if (event.GetType() == "change") { if (m_delegate != NULL && element->GetOwnerDocument()->IsVisible()) { Rocket::Core::Element *menu_item = element->GetParentNode()->GetParentNode(); RangeData *data = GetRangeData(menu_item); const Rocket::Core::Dictionary *p = event.GetParameters(); float v = p->Get("value")->Get<float>(); float new_value = data->min + v*(data->max - data->min); if (fabs(new_value-data->value) > 0.001f) { data->value = new_value; m_delegate->DidChangeRangeValue(menu_item, data->value); } } } }