本文整理汇总了C++中core::Element::AddEventListener方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::AddEventListener方法的具体用法?C++ Element::AddEventListener怎么用?C++ Element::AddEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core::Element
的用法示例。
在下文中一共展示了Element::AddEventListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddOption
// Adds a new option to the select control.
int WidgetDropDown::AddOption(const Rocket::Core::String& rml, const Rocket::Core::String& value, int before, bool select, bool selectable)
{
// Instance a new element for the option.
Core::Element* element = Core::Factory::InstanceElement(selection_element, "*", "option", Rocket::Core::XMLAttributes());
// Force to block display and inject the RML. Register a click handler so we can be notified of selection.
element->SetProperty("display", "block");
element->SetProperty("clip", "auto");
element->SetInnerRML(rml);
element->AddEventListener("click", this);
int option_index;
if (before < 0 ||
before >= (int) options.size())
{
selection_element->AppendChild(element);
options.push_back(SelectOption(element, value, selectable));
option_index = (int) options.size() - 1;
}
else
{
selection_element->InsertBefore(element, selection_element->GetChild(before));
options.insert(options.begin() + before, SelectOption(element, value, selectable));
option_index = before;
}
element->RemoveReference();
// Select the option if appropriate.
if (select)
SetSelection(option_index);
box_layout_dirty = true;
return option_index;
}