MCPcopy Create free account
hub / github.com/TankOs/SFGUI / HandleEvent

Method HandleEvent

src/SFGUI/Container.cpp:56–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void Container::HandleEvent( const sf::Event& event ) {
57 // Ignore event when widget is not visible.
58 if( !IsGloballyVisible() ) {
59 return;
60 }
61
62 // Create a copy of the event and transform mouse coordinates to local
63 // coordinates if event is a mouse event.
64 sf::Event local_event( event );
65
66 if( const auto* mouseMoved = local_event.getIf<sf::Event::MouseMoved>() ) {
67 local_event = sf::Event::MouseMoved{ mouseMoved->position - sf::Vector2i( GetAllocation().position ) };
68 }
69
70 if( const auto* mouseButtonPressed = local_event.getIf<sf::Event::MouseButtonPressed>()) {
71 local_event = sf::Event::MouseButtonPressed{ mouseButtonPressed->button, mouseButtonPressed->position - sf::Vector2i( GetAllocation().position ) };
72 }
73 if( const auto* mouseButtonReleased = local_event.getIf<sf::Event::MouseButtonReleased>()) {
74 local_event = sf::Event::MouseButtonReleased{ mouseButtonReleased->button, mouseButtonReleased->position - sf::Vector2i( GetAllocation().position ) };
75 }
76
77 // Pass event to children.
78 for( const auto& child : m_children ) {
79 child->HandleEvent( local_event );
80 }
81
82 // Process event for own widget.
83 Widget::HandleEvent( event );
84}
85
86bool Container::HandleAdd( Widget::Ptr child ) {
87 if( IsChild( child ) ) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected