示例#1
0
void Window::MouseEvent( int what, int x, int y, unsigned int buttons )
{

    // Backwards, as added.
    lock();
    for ( int i = CountChildren() - 1; i >= 0; i-- )
    {
        View *view = ChildAt(i);

        if ( view->Frame().Contains( x,y ) )
        {
            int nx = x - view->Frame().left;
            int ny = y - view->Frame().top;

            SetActiveView( view );
            view->MouseEvent( what, nx, ny, buttons );
            break;
        }
    }
    unlock();

}
示例#2
0
void View::MouseEvent( int what, int x, int y, unsigned int buttons )
{

			// Backwards, as added.
  lock();
  for ( int i = CountChildren() - 1; i >= 0; i-- )  
  {
     View *view = ChildAt(i);

        if ( view->Frame().Contains( x,y ) )
         {
		   int nx = x - view->Frame().left;
		   int ny = y - view->Frame().top;

		   if ( GetWindow() != NULL ) GetWindow()->SetActiveView( view );
		   
		   view->MouseEvent( what, nx, ny, buttons );
		   unlock();
		   return;
	  	 }
  }
  unlock();
 

	// Otherwise...
 
  	   switch( what )
	   {
	     case MOUSE_DOWN:
            MouseDown( x, y, buttons );
		    break;
	     case MOUSE_UP:
			if ( hasFlag( HAS_POPUPMENU ) == false )
			{
			   MouseUp( x, y, buttons );
			   break;
			}
			// Only the right mouse button.
			
			if ( m_buttons != RIGHT_MOUSE_BUTTON )
			{
				MouseUp( x, y, buttons );
				break;
			}

			if ( m_popupMenu == NULL ) m_popupMenu = Popup();
			if ( m_popupMenu == NULL ) return;
			
			m_popupMenu->MoveTo(  x - m_popupMenu->Frame().Width() / 2,
								  y - m_popupMenu->Frame().Height() / 2 );
			
			m_popupMenu->Show();
		    break;

	     case MOUSE_MOVED:
            MouseMoved( x, y, buttons );
		    break;
	   }

	m_buttons = buttons;
}