pub fn handle_event(&mut self, event: Event) -> Vec<&PushrodEvent> {
        let mut return_vector: Vec<&PushrodEvent> = Vec::new();

        match event {
            Event::MouseButtonDown {
                mouse_btn,
                clicks,
                x,
                y,
                ..
            } => {
                eprintln!(
                    "[WidgetCache::handle_event] mouse down: button={} clicks={} x={} y={}",
                    mouse_btn as i32, clicks, x, y
                );
            }

            Event::MouseButtonUp {
                mouse_btn,
                clicks,
                x,
                y,
                ..
            } => {
                eprintln!(
                    "[WidgetCache::handle_event] mouse up: button={} clicks={} x={} y={}",
                    mouse_btn as i32, clicks, x, y
                );
            }

            Event::MouseMotion {
                timestamp,
                window_id,
                which,
                mousestate,
                x,
                y,
                xrel,
                yrel,
            } => {
                let mut x_offset = 0;
                let mut y_offset = 0;
                let previous_widget_id = self.current_widget_id;

                self.current_widget_id = self.get_widget_id(x, y);

                // Send previous widget ID event that an event left it bounds
                // Send current widget ID event that event entered its bounds
                if self.current_widget_id != previous_widget_id {
                    let exited_event = PushrodEvent::ExitedBounds(previous_widget_id);
                    let entered_event = PushrodEvent::EnteredBounds(self.current_widget_id);

                    // Exited event - copy return events only if some are generated
                    if let Some(x) =
                        self.send_and_receive_event_to_widget(previous_widget_id, exited_event)
                    {
                        for i in 0..x.len() {
                            return_vector.push(&x[i]);
                        }
                    }

                    // Entered event
                    if let Some(x) =
                        self.send_and_receive_event_to_widget(self.current_widget_id, entered_event)
                    {
                        for i in 0..x.len() {
                            return_vector.push(&x[i]);
                        }
                    }
                }

                match &self.cache[self.current_widget_id as usize] {
                    SystemWidget::Base(x) => {
                        x_offset = x.get_origin().x;
                        y_offset = x.get_origin().y;
                    }

                    SystemWidget::Box(x) => {
                        x_offset = x.get_origin().x;
                        y_offset = x.get_origin().y;
                    }

                    SystemWidget::Button(x) => {
                        x_offset = x.get_origin().x;
                        y_offset = x.get_origin().y;
                    }

                    _unused => {
                        // Do nothing
                        eprintln!(
                            "[WidgetCache::handle_event] I am trying to handle an event with a widget that I can't handle yet!"
                        );
                    }
                }

                if let Some(x) = self.send_and_receive_event_to_widget(
                    self.current_widget_id,
                    PushrodEvent::SystemEvent(Event::MouseMotion {
                        timestamp,
                        window_id,
                        which,
                        mousestate,
                        x: x - x_offset,
                        y: y - y_offset,
                        xrel,
                        yrel,
                    }),
                ) {
                    for i in 0..x.len() {
                        return_vector.push(&x[i]);
                    }
                }
            }

            _default => {}
        }

        return_vector
    }
/// This handles the direct events from the `Engine` class.  Events are not handled by the
/// `Engine` via indirection.  They are handled by the `Cache`, so that objects that are
/// selected or have focus are handled by this class.
This handles the direct events from the `Engine` class.  Events are not handled by the
`Engine` via indirection.  They are handled by the `Cache`, so that objects that are
selected or have focus are handled by this class.
This handles the direct events from the ` Engine ` class . Events are not handled by the ` Engine ` via indirection . They are handled by the ` Cache ` so that objects that are selected or have focus are handled by this class .
pub fn handle_event(&mut self, event: Event) -> Vec<&PushrodEvent> {
        let mut return_vector: Vec<&PushrodEvent> = Vec::new();
        match event {
            Event::MouseButtonDown {
                mouse_btn,
                clicks,
                x,
                y,
                ..
            } => {
                eprintln!(
                    "[WidgetCache::handle_event] mouse down: button={} clicks={} x={} y={}",
                    mouse_btn as i32, clicks, x, y
                );
            }
            Event::MouseButtonUp {
                mouse_btn,
                clicks,
                x,
                y,
                ..
            } => {
                eprintln!(
                    "[WidgetCache::handle_event] mouse up: button={} clicks={} x={} y={}",
                    mouse_btn as i32, clicks, x, y
                );
            }
            Event::MouseMotion {
                timestamp,
                window_id,
                which,
                mousestate,
                x,
                y,
                xrel,
                yrel,
            } => {
                let mut x_offset = 0;
                let mut y_offset = 0;
                let previous_widget_id = self.current_widget_id;
                self.current_widget_id = self.get_widget_id(x, y);
                // Send previous widget ID event that an event left it bounds
                // Send current widget ID event that event entered its bounds
                if self.current_widget_id != previous_widget_id {
                    let exited_event = PushrodEvent::ExitedBounds(previous_widget_id);
                    let entered_event = PushrodEvent::EnteredBounds(self.current_widget_id);
                    // Exited event - copy return events only if some are generated
                    if let Some(x) =
                        self.send_and_receive_event_to_widget(previous_widget_id, exited_event)
                    {
                        for i in 0..x.len() {
                            return_vector.push(&x[i]);
                        }
                    }
                    // Entered event
                    if let Some(x) =
                        self.send_and_receive_event_to_widget(self.current_widget_id, entered_event)
                    {
                        for i in 0..x.len() {
                            return_vector.push(&x[i]);
                        }
                    }
                }
                match &self.cache[self.current_widget_id as usize] {
                    SystemWidget::Base(x) => {
                        x_offset = x.get_origin().x;
                        y_offset = x.get_origin().y;
                    }
                    SystemWidget::Box(x) => {
                        x_offset = x.get_origin().x;
                        y_offset = x.get_origin().y;
                    }
                    SystemWidget::Button(x) => {
                        x_offset = x.get_origin().x;
                        y_offset = x.get_origin().y;
                    }
                    _unused => {
                        // Do nothing
                        eprintln!(
                            "[WidgetCache::handle_event] I am trying to handle an event with a widget that I can't handle yet!"
                        );
                    }
                }
                if let Some(x) = self.send_and_receive_event_to_widget(
                    self.current_widget_id,
                    PushrodEvent::SystemEvent(Event::MouseMotion {
                        timestamp,
                        window_id,
                        which,
                        mousestate,
                        x: x - x_offset,
                        y: y - y_offset,
                        xrel,
                        yrel,
                    }),
                ) {
                    for i in 0..x.len() {
                        return_vector.push(&x[i]);
                    }
                }
            }
            _default => {}
        }
        return_vector
    }
pub fn handle_event ( & mut self , event : Event ) -> Vec < & PushrodEvent > { let mut return_vector : Vec < & PushrodEvent > = Vec :: new ( ) ; match event { Event :: MouseButtonDown { mouse_btn , clicks , x , y , .. } => { eprintln ! ( " " mouse_btn as i32 clicks x y ) ; } Event :: MouseButtonUp { mouse_btn , clicks , x , y , .. } => { eprintln ! ( " " mouse_btn as i32 clicks x y ) ; } Event :: MouseMotion { timestamp , window_id , which , mousestate , x , y , xrel , yrel , } => { let mut x_offset = 0 ; let mut y_offset = 0 ; let previous_widget_id = self . current_widget_id ; self . current_widget_id = self . get_widget_id ( x , y ) ; // Send previous widget ID event that an event left it bounds // Send current widget ID event that event entered its bounds if self . current_widget_id != previous_widget_id { let exited_event = PushrodEvent :: ExitedBounds ( previous_widget_id ) ; let entered_event = PushrodEvent :: EnteredBounds ( self . current_widget_id ) ; // Exited event - copy return events only if some are generated if let Some ( x ) = self . send_and_receive_event_to_widget ( previous_widget_id , exited_event ) { for i in 0 .. x . len ( ) { return_vector . push ( & x [ i ] ) ; } } // Entered event if let Some ( x ) = self . send_and_receive_event_to_widget ( self . current_widget_id , entered_event ) { for i in 0 .. x . len ( ) { return_vector . push ( & x [ i ] ) ; } } } match & self . cache [ self . current_widget_id as usize ] { SystemWidget :: Base ( x ) => { x_offset = x . get_origin ( ) . x ; y_offset = x . get_origin ( ) . y ; } SystemWidget :: Box ( x ) => { x_offset = x . get_origin ( ) . x ; y_offset = x . get_origin ( ) . y ; } SystemWidget :: Button ( x ) => { x_offset = x . get_origin ( ) . x ; y_offset = x . get_origin ( ) . y ; } _unused => { // Do nothing eprintln ! ( " " ) ; } } if let Some ( x ) = self . send_and_receive_event_to_widget ( self . current_widget_id , PushrodEvent :: SystemEvent ( Event :: MouseMotion { timestamp , window_id , which , mousestate , x : x - x_offset , y : y - y_offset , xrel , yrel , } ) , ) { for i in 0 .. x . len ( ) { return_vector . push ( & x [ i ] ) ; } } } _default => { } } return_vector }
This handles the direct events from the `Engine` class.
This handles the direct events from the ` Engine ` class .
&mut self
event
Event
&mut self
event
Event