当前位置: 首页>>代码示例>>C++>>正文


C++ Element::DispatchEvent方法代码示例

本文整理汇总了C++中rocket::core::Element::DispatchEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::DispatchEvent方法的具体用法?C++ Element::DispatchEvent怎么用?C++ Element::DispatchEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rocket::core::Element的用法示例。


在下文中一共展示了Element::DispatchEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CardsPageDataSource

TEST_F( libRocketDataGridTest, UIDataViewList )
{
  Point2i pos1(60,25);
  std::string doc_file1 = "dataview.rml";

  UIDataViewList store1;
  EXPECT_EQ( true, store1.set_context(&this->desktop) );
  EXPECT_EQ( true, store1.load_document_file( doc_file1 ) )
  << this->test_set() << " object should not be invalid; is the context and document file valid?";

  // Ensure that the visual debugger's beacon (err icon) appears on-screen.
  Rocket::Core::Log::Message( Rocket::Core::Log::LT_ASSERT, "Hello, world!" );

  this->model.reset( new CardsPageDataSource("cards_db") );
  this->db.reset( new CardCollection() );
  EXPECT_TRUE( model != nullptr );
  EXPECT_TRUE( db != nullptr );

  EXPECT_EQ( true, db->load_db() )
  << "Could not initialize nom::CardsPageDataSource data interface.";

  CardList deck;
  CardList cards = db->cards();

  // Load in the entire cards database
  for( auto itr = cards.begin(); itr != cards.end(); ++itr )
  {
    deck.push_back( *itr );
  }

  // Deck of cards for the data source
  model->append_cards( deck );

  store1.show();

  EXPECT_TRUE( store1.set_column_title(1, "CARDS P. " + std::to_string(model->page() + 1) ) );

  EXPECT_EQ( true, store1.visible() );
  EXPECT_EQ( pos1, store1.position() );

  // Default values sanity

  EXPECT_EQ( "cards", model->table_name() );

  EXPECT_EQ( 11, model->per_page() );
  EXPECT_EQ( 0, model->page() );

  EXPECT_EQ( 10, model->map_page_row( 10, 0 ) )
  << "Selection should be between 0..11";

  EXPECT_EQ( 2, model->map_page_row( 13, 1 ) )
  << "Selection should be between 0..11";

  EXPECT_EQ( 10, model->map_page_row( 21, 1 ) )
  << "Selection should be between 0..11";

  EXPECT_EQ( "CARDS P. 1", store1.column_title(1) );
  EXPECT_EQ( "NUM.", store1.column_title(2) );

  store1.register_event_listener( store1.document(), "keydown", new nom::UIEventListener( [&]
    ( Rocket::Core::Event& ev ) { on_keydown( ev, &store1, db, model, this->phand ); }
  ));

  store1.register_event_listener( store1.document(), "mouseup", new nom::UIEventListener( [&]
    ( Rocket::Core::Event& ev ) { on_mouseup( ev, &store1, db, model, this->phand ); }
  ));

  // Synthesized user input events; we hope to capture these before the end of
  // the first frame
  Rocket::Core::Element* target = nullptr;
  Rocket::Core::Dictionary lclick;
  Rocket::Core::Dictionary rclick;
  lclick.Set("button","0"); // Left click
  rclick.Set("button","1"); // Left click

  // We must update the context before our cards model is filled
  this->desktop.update();

  target = store1.document()->GetElementById("Geezard");
  if( target ) {
    target->DispatchEvent("mouseup", lclick);
    // Should have zero cards remaining
  }

  target = store1.document()->GetElementById("Red Bat");
  if( target ) {
    target->DispatchEvent("mouseup", lclick);
    target->DispatchEvent("mouseup", lclick);
    target->DispatchEvent("mouseup", lclick);
    // Should have one cards remaining
  }

  target = store1.document()->GetElementById("Red Bat");
  if( target ) {
    target->DispatchEvent("mouseup", rclick);
    // Should have two cards remaining
  }

  target = store1.document()->GetElementById("Cockatrice");
  if( target ) {
//.........这里部分代码省略.........
开发者ID:i8degrees,项目名称:nomlib,代码行数:101,代码来源:libRocketDataGridTest.cpp


注:本文中的rocket::core::Element::DispatchEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。