Add handling LEFT_UP
This commit is contained in:
@@ -187,6 +187,7 @@ protected:
|
|||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnLeftDown(wxMouseEvent& event);
|
void OnLeftDown(wxMouseEvent& event);
|
||||||
|
void OnLeftUp(wxMouseEvent& event);
|
||||||
void OnMouseMove(wxMouseEvent& event);
|
void OnMouseMove(wxMouseEvent& event);
|
||||||
void OnKeyDown(wxKeyEvent& event);
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
void OnKillFocus(wxFocusEvent& event);
|
void OnKillFocus(wxFocusEvent& event);
|
||||||
|
@@ -181,6 +181,7 @@ protected:
|
|||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnLeftDown(wxMouseEvent& event);
|
void OnLeftDown(wxMouseEvent& event);
|
||||||
|
void OnLeftUp(wxMouseEvent& event);
|
||||||
void OnMouseMove(wxMouseEvent& event);
|
void OnMouseMove(wxMouseEvent& event);
|
||||||
void OnMouseLeave(wxMouseEvent& event);
|
void OnMouseLeave(wxMouseEvent& event);
|
||||||
void OnKeyDown(wxKeyEvent& event);
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
@@ -282,6 +283,7 @@ wxBEGIN_EVENT_TABLE(wxPopupMenuWindow, wxPopupTransientWindow)
|
|||||||
EVT_KEY_DOWN(wxPopupMenuWindow::OnKeyDown)
|
EVT_KEY_DOWN(wxPopupMenuWindow::OnKeyDown)
|
||||||
|
|
||||||
EVT_LEFT_DOWN(wxPopupMenuWindow::OnLeftDown)
|
EVT_LEFT_DOWN(wxPopupMenuWindow::OnLeftDown)
|
||||||
|
EVT_LEFT_UP(wxPopupMenuWindow::OnLeftUp)
|
||||||
EVT_MOTION(wxPopupMenuWindow::OnMouseMove)
|
EVT_MOTION(wxPopupMenuWindow::OnMouseMove)
|
||||||
EVT_LEAVE_WINDOW(wxPopupMenuWindow::OnMouseLeave)
|
EVT_LEAVE_WINDOW(wxPopupMenuWindow::OnMouseLeave)
|
||||||
EVT_MOUSE_CAPTURE_LOST(wxPopupMenuWindow::OnCaptureLost)
|
EVT_MOUSE_CAPTURE_LOST(wxPopupMenuWindow::OnCaptureLost)
|
||||||
@@ -294,6 +296,7 @@ wxBEGIN_EVENT_TABLE(wxMenuBar, wxMenuBarBase)
|
|||||||
EVT_KILL_FOCUS(wxMenuBar::OnKillFocus)
|
EVT_KILL_FOCUS(wxMenuBar::OnKillFocus)
|
||||||
EVT_KEY_DOWN(wxMenuBar::OnKeyDown)
|
EVT_KEY_DOWN(wxMenuBar::OnKeyDown)
|
||||||
EVT_LEFT_DOWN(wxMenuBar::OnLeftDown)
|
EVT_LEFT_DOWN(wxMenuBar::OnLeftDown)
|
||||||
|
EVT_LEFT_UP(wxMenuBar::OnLeftUp)
|
||||||
EVT_MOTION(wxMenuBar::OnMouseMove)
|
EVT_MOTION(wxMenuBar::OnMouseMove)
|
||||||
EVT_MOUSE_CAPTURE_LOST(wxMenuBar::OnCaptureLost)
|
EVT_MOUSE_CAPTURE_LOST(wxMenuBar::OnCaptureLost)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
@@ -356,7 +359,7 @@ void wxPopupMenuWindow::ChangeCurrent(wxMenuItemIter node)
|
|||||||
wxCHECK_RET( item, wxT("no current item?") );
|
wxCHECK_RET( item, wxT("no current item?") );
|
||||||
|
|
||||||
// if it was the currently opened menu, close it
|
// if it was the currently opened menu, close it
|
||||||
if ( item->IsSubMenu() && item->GetSubMenu()->IsShown() )
|
if ( node && item->IsSubMenu() && item->GetSubMenu()->IsShown() )
|
||||||
{
|
{
|
||||||
item->GetSubMenu()->Dismiss();
|
item->GetSubMenu()->Dismiss();
|
||||||
OnSubmenuDismiss( false );
|
OnSubmenuDismiss( false );
|
||||||
@@ -722,6 +725,18 @@ bool wxPopupMenuWindow::ProcessLeftDown(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxPopupMenuWindow::OnLeftDown(wxMouseEvent& event)
|
void wxPopupMenuWindow::OnLeftDown(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
wxMenuBar* menubar = m_menu->GetMenuBar();
|
||||||
|
if ( menubar && !GetMenuItemFromPoint(event.GetPosition()) && !ProcessLeftDown(event) )
|
||||||
|
{
|
||||||
|
wxPoint pos = event.GetPosition();
|
||||||
|
wxPoint posScreen = ClientToScreen(pos);
|
||||||
|
event.SetPosition(menubar->ScreenToClient(posScreen));
|
||||||
|
menubar->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxPopupMenuWindow::OnLeftUp(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
wxMenuItemIter node = GetMenuItemFromPoint(event.GetPosition());
|
wxMenuItemIter node = GetMenuItemFromPoint(event.GetPosition());
|
||||||
if ( node )
|
if ( node )
|
||||||
@@ -733,6 +748,9 @@ void wxPopupMenuWindow::OnLeftDown(wxMouseEvent& event)
|
|||||||
wxMenuBar* menubar = m_menu->GetMenuBar();
|
wxMenuBar* menubar = m_menu->GetMenuBar();
|
||||||
if ( menubar && !ProcessLeftDown(event) )
|
if ( menubar && !ProcessLeftDown(event) )
|
||||||
{
|
{
|
||||||
|
wxPoint pos = event.GetPosition();
|
||||||
|
wxPoint posScreen = ClientToScreen(pos);
|
||||||
|
event.SetPosition(menubar->ScreenToClient(posScreen));
|
||||||
menubar->ProcessEvent(event);
|
menubar->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2129,14 +2147,25 @@ void wxMenuBar::OnLeftDown(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
else // we didn't have mouse capture, capture it now
|
else // we didn't have mouse capture, capture it now
|
||||||
{
|
{
|
||||||
m_current = GetMenuFromPoint(event.GetPosition());
|
int item = GetMenuFromPoint(event.GetPosition());
|
||||||
if ( m_current == -1 )
|
if ( item == -1 )
|
||||||
{
|
{
|
||||||
DismissMenu(); // event outside menubar - dismiss
|
if ( IsShowingMenu() )
|
||||||
ReleaseMouseCapture(); // we could get capture back from popup window so release it
|
{
|
||||||
|
DismissMenu(); // event outside menubar - dismiss
|
||||||
|
ReleaseMouseCapture(); // we could get capture back from popup window so release it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( item == m_current && IsShowingMenu() )
|
||||||
|
{
|
||||||
|
// double-click
|
||||||
|
DismissMenu();
|
||||||
|
ReleaseMouseCapture();
|
||||||
}
|
}
|
||||||
else // on item
|
else // on item
|
||||||
{
|
{
|
||||||
|
m_current = item;
|
||||||
|
|
||||||
wxLogTrace(wxT("mousecapture"), wxT("Capturing mouse from wxMenuBar::OnLeftDown"));
|
wxLogTrace(wxT("mousecapture"), wxT("Capturing mouse from wxMenuBar::OnLeftDown"));
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
|
|
||||||
@@ -2149,6 +2178,15 @@ void wxMenuBar::OnLeftDown(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMenuBar::OnLeftUp(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
if ( !HasCapture() && IsShowingMenu() && GetMenuFromPoint(event.GetPosition()) == -1 )
|
||||||
|
{
|
||||||
|
DismissMenu();
|
||||||
|
ReleaseMouseCapture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxMenuBar::OnMouseMove(wxMouseEvent& event)
|
void wxMenuBar::OnMouseMove(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
if ( HasCapture() )
|
if ( HasCapture() )
|
||||||
@@ -2332,9 +2370,12 @@ void wxMenuBar::OnKeyDown(wxKeyEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMenuBar::OnCaptureLost(wxMouseCaptureLostEvent& event)
|
void wxMenuBar::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
DismissMenu();
|
if ( IsShowingMenu() )
|
||||||
|
{
|
||||||
|
DismissMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user