void ElementDataGrid::ProcessEvent(Core::Event& event)
{
	Core::Element::ProcessEvent(event);

	if (event == "columnadd")
	{
		if (event.GetTargetElement() == this)
		{
			root->RefreshRows();
			DirtyLayout();
		}
	}
	else if (event == "resize")
	{
		if (event.GetTargetElement() == this)
		{
			SetScrollTop(GetScrollHeight() - GetClientHeight());

			for (int i = 0; i < header->GetNumChildren(); i++)
			{
				Core::Element* child = header->GetChild(i);
				columns[i].current_width = child->GetBox().GetSize(Core::Box::MARGIN).x;
			}
		}
	}
}
void ElementDataGrid::ProcessEvent(Core::Event& event)
{
	Core::Element::ProcessEvent(event);

	if (event == "columnadd")
	{
		if (event.GetTargetElement() == this)
		{
			root->RefreshRows();
			DirtyLayout();
		}
	}
	else if (event == "resize")
	{
		if (event.GetTargetElement() == this)
		{
			// commented this out because this bugs selection on overflowed 
			// datagrids contained within another overflowed element
			//SetScrollTop(GetScrollHeight() - GetClientHeight());

			for (int i = 0; i < header->GetNumChildren(); i++)
			{
				Core::Element* child = header->GetChild(i);
				columns[i].current_width = child->GetBox().GetSize(Core::Box::MARGIN).x;
			}
		}
	}
}
void WidgetDropDown::ProcessEvent(Core::Event& event)
{
	// Process the button onclick
	if (event == "click" &&
		!parent_element->IsDisabled())
	{

		if (event.GetCurrentElement()->GetParentNode() == selection_element)
		{
			// Find the element in the options and fire the selection event
			for (size_t i = 0; i < options.size(); i++)
			{
				if (options[i].GetElement() == event.GetCurrentElement())
				{
					if (options[i].IsSelectable())
					{
						SetSelection(i);
						event.StopPropagation();

						ShowSelectBox(false);
						parent_element->Focus();
					}
				}
			}
		}
		else
		{
			// We have to check that this event isn't targeted to an element
			// inside the selection box as we'll get all events coming from our
			// root level select element as well as the ones coming from options (which
			// get caught in the above if)
			Core::Element* element = event.GetTargetElement();
			while (element && element != parent_element)
			{
				if (element == selection_element)
					return;
				element = element->GetParentNode();
			}

			if (selection_element->GetProperty< int >("visibility") == Core::VISIBILITY_HIDDEN)
				ShowSelectBox(true);
			else
				ShowSelectBox(false);
		}		
	}
	else if (event == "blur" && event.GetTargetElement() == parent_element)
		ShowSelectBox(false);
}
// Process the incoming event.
void ElementTabSet::ProcessEvent(Core::Event& event)
{
	Core::Element::ProcessEvent(event);

	if (event.GetCurrentElement() == this && event == "click")
	{
		// Find the tab that this click occured on
		Core::Element* tabs = GetChildByTag("tabs");
		Core::Element* tab = event.GetTargetElement();
		while (tab && tab != this && tab->GetParentNode() != tabs)
			tab = tab->GetParentNode();

		// Abort if we couldn't find the tab the click occured on
		if (!tab || tab == this)
			return;

		// Determine the new active tab index
		int new_active_tab = active_tab;
		for (int i = 0; i < tabs->GetNumChildren(); i++)
		{
			if (tabs->GetChild(i) == tab)
			{
				new_active_tab = i;
				break;
			}
		}

		SetActiveTab(new_active_tab);
	}
}
void ElementLabel::ProcessEvent(Core::Event& event)
{
	// Detect click events
	if (event.GetTargetElement() == this &&	(event == "click"))
	{
		if (this->HasAttribute("for"))
		{
			Core::Element* forElement = this->GetOwnerDocument()->GetElementById(this->GetAttribute<Core::String>("for", ""));
			if (forElement != NULL)
			{
				forElement->ProcessEvent(event);
			}
		}
		else
		{
			//Note that we have to loop since the ElementFormControlInput class does not pass its OnChildAdded to the superclass.
			//We don't want to modify things too much, so we will just loop when clicked searching for the child input, not really
			//a big deal.
			int childCount = this->GetNumChildren();
			Core::Element* child;
			for (int i = 0; i < childCount; ++i)
			{
				child = this->GetChild(i);
				if (child->GetTagName() == "input")
				{
					child->ProcessEvent(event);
					i = childCount; //break loop
				}
			}
		}
	}

	Element::ProcessEvent(event);
}
Exemple #6
0
void ElementLog::ProcessEvent(Core::Event& event)
{
	Core::Element::ProcessEvent(event);

	// Only process events if we're visible
	if (beacon != NULL)
	{
		if (event == "click")
		{
			if (event.GetTargetElement() == beacon->GetFirstChild())
			{
				if (!IsVisible())
					SetProperty("visibility", "visible");

				beacon->SetProperty("visibility", "hidden");
				current_beacon_level = Core::Log::LT_MAX;
			}
			else if (event.GetTargetElement()->GetId() == "close_button")
			{
				if (IsVisible())
					SetProperty("visibility", "hidden");
			}
			else
			{
				for (int i = 0; i < Core::Log::LT_MAX; i++)
				{
					if (!log_types[i].button_name.Empty() && event.GetTargetElement()->GetId() == log_types[i].button_name)
					{
						log_types[i].visible = !log_types[i].visible;
						if (log_types[i].visible)
							event.GetTargetElement()->SetInnerRML("On");
						else
							event.GetTargetElement()->SetInnerRML("Off");
						dirty_logs = true;
					}
				}
			}
		}
	}

	if (event == "resize" && auto_scroll)
	{
		if (message_content != NULL &&
			message_content->HasChildNodes())
			message_content->GetLastChild()->ScrollIntoView();
	}
}
// Checks for necessary functional changes in the control as a result of the event.
void InputTypeButton::ProcessEvent(Core::Event& event)
{
	// Stop a click event from proceeding any further if this button is disabled.
	if (event.GetTargetElement() == element &&
		element->IsDisabled() &&
		(event == "click" || event == "dblclick"))
	{
		event.StopPropagation();
	}
}
void ElementDataGridCell::ProcessEvent(Core::Event& event)
{
    Core::Element::ProcessEvent(event);

    if (event == "resize")
    {
        if (event.GetTargetElement() == header)
        {
            SetProperty("width", Core::Property(header->GetBox().GetSize(Core::Box::MARGIN).x, Core::Property::PX));
        }
    }
}
Exemple #9
0
// Event handler for events from the debugger elements.
void Plugin::ProcessEvent(Core::Event& event)
{
	if (event == "click")
	{
		if (event.GetTargetElement()->GetId() == "event-log-button")
		{
			if (log_element->IsVisible())
				log_element->SetProperty("visibility", "hidden");
			else
				log_element->SetProperty("visibility", "visible");
		}
		else if (event.GetTargetElement()->GetId() == "debug-info-button")
		{
			if (info_element->IsVisible())
				info_element->SetProperty("visibility", "hidden");
			else
				info_element->SetProperty("visibility", "visible");
		}
		else if (event.GetTargetElement()->GetId() == "outlines-button")
		{
			render_outlines = !render_outlines;
		}
	}
}
Exemple #10
0
void WidgetDropDown::ProcessEvent(Core::Event& event)
{
	if (parent_element->IsDisabled()) 
		return;

	// Process the button onclick
	if (event == "click")
	{

		if (event.GetCurrentElement()->GetParentNode() == selection_element)
		{
			// Find the element in the options and fire the selection event
			for (size_t i = 0; i < options.size(); i++)
			{
				if (options[i].GetElement() == event.GetCurrentElement())
				{
					if (options[i].IsSelectable())
					{
						SetSelection(i);
						event.StopPropagation();

						ShowSelectBox(false);
						parent_element->Focus();
					}
				}
			}
		}
		else
		{
			// We have to check that this event isn't targeted to an element
			// inside the selection box as we'll get all events coming from our
			// root level select element as well as the ones coming from options (which
			// get caught in the above if)
			Core::Element* element = event.GetTargetElement();
			while (element && element != parent_element)
			{
				if (element == selection_element)
					return;
				element = element->GetParentNode();
			}

			if (selection_element->GetProperty< int >("visibility") == Core::VISIBILITY_HIDDEN)
				ShowSelectBox(true);
			else
				ShowSelectBox(false);
		}		
	}
	else if (event == "blur" && event.GetTargetElement() == parent_element)
	{
		ShowSelectBox(false);
	}
	else if (event == "keydown")
	{
		Core::Input::KeyIdentifier key_identifier = (Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0);

		switch (key_identifier)
		{
			case Core::Input::KI_UP:
				SetSelection( (selected_option - 1 + options.size()) % options.size() );
				break;
			case Core::Input::KI_DOWN:		
				SetSelection( (selected_option + 1) % options.size() );
				break;
			default:
				break;
		}
	}

	if (event.GetTargetElement() == parent_element)
	{
		if (event == "focus")
		{
			value_element->SetPseudoClass("focus", true);
			button_element->SetPseudoClass("focus", true);
		}
		else if (event == "blur")
		{
			value_element->SetPseudoClass("focus", false);
			button_element->SetPseudoClass("focus", false);
		}
	}

}
void ElementInfo::ProcessEvent(Core::Event& event)
{
	Core::ElementDocument::ProcessEvent(event);

	// Only process events if we're visible
	if (IsVisible())
	{
		if (event == "click")
		{
			Core::Element* target_element = event.GetTargetElement();

			// Deal with clicks on our own elements differently.
			if (target_element->GetOwnerDocument() == this)
			{
				// If it's a pane title, then we need to toggle the visibility of its sibling (the contents pane underneath it).
				if (target_element->GetTagName() == "h2")
				{
					Core::Element* panel = target_element->GetNextSibling();
					if (panel->IsVisible())
						panel->SetProperty("display", "none");
					else
						panel->SetProperty("display", "block");
					event.StopPropagation();
				}
				else if (event.GetTargetElement()->GetId() == "close_button")
				{
					if (IsVisible())
						SetProperty("visibility", "hidden");
				}
				// Check if the id is in the form "a %d" or "c %d" - these are the ancestor or child labels.
				else
				{
					int element_index;
					if (sscanf(target_element->GetId().CString(), "a %d", &element_index) == 1)
					{
						Core::Element* new_source_element = source_element;
						for (int i = 0; i < element_index; i++)
						{
							if (new_source_element != NULL)
								new_source_element = new_source_element->GetParentNode();
						}
						SetSourceElement(new_source_element);
					}
					else if (sscanf(target_element->GetId().CString(), "c %d", &element_index) == 1)
					{
						if (source_element != NULL)
							SetSourceElement(source_element->GetChild(element_index));
					}
					event.StopPropagation();
				}
			}
			// Otherwise we just want to focus on the clicked element (unless it's on a debug element)
			else if (target_element->GetOwnerDocument() != NULL && !IsDebuggerElement(target_element))
			{
				Core::Element* new_source_element = target_element;
				if (new_source_element != source_element)
				{
					SetSourceElement(new_source_element);
					event.StopPropagation();
				}
			}
		}
		else if (event == "mouseover")
		{
			Core::Element* target_element = event.GetTargetElement();

			// Deal with clicks on our own elements differently.
			Core::ElementDocument* owner_document = target_element->GetOwnerDocument();
			if (owner_document == this)
			{
				// Check if the id is in the form "a %d" or "c %d" - these are the ancestor or child labels.
				int element_index;
				if (sscanf(target_element->GetId().CString(), "a %d", &element_index) == 1)
				{
					hover_element = source_element;
					for (int i = 0; i < element_index; i++)
					{
						if (hover_element != NULL)
							hover_element = hover_element->GetParentNode();
					}
				}
				else if (sscanf(target_element->GetId().CString(), "c %d", &element_index) == 1)
				{
					if (source_element != NULL)
						hover_element = source_element->GetChild(element_index);
				}
			}
			// Otherwise we just want to focus on the clicked element (unless it's on a debug element)
			else if (owner_document != NULL && owner_document->GetId().Find("rkt-debug-") != 0)
			{
				hover_element = target_element;
			}
		}
	}
}