Browse Source

pop up now closes on lbuttondown or rbuttondown and if the escapte key is pressed

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@30 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 22 years ago
parent
commit
042b306b29
1 changed files with 25 additions and 6 deletions
  1. 25 6
      QListCtrl.cpp

+ 25 - 6
QListCtrl.cpp

@@ -594,10 +594,24 @@ BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
 
 	switch(pMsg->message) 
 	{
+	case WM_LBUTTONDOWN:
+	case WM_RBUTTONDOWN:
+		if(m_Popup.m_bIsShowing)
+		{
+			m_Popup.Hide();
+		}
+		break;
 	case WM_KEYDOWN:
-		m_Popup.Hide(); // hide the manual tooltip on any keypress
-
 		WPARAM vk = pMsg->wParam;
+		
+		if(m_Popup.m_bIsShowing)
+		{
+			m_Popup.Hide();
+
+			if(vk == VK_ESCAPE)
+				return TRUE;
+		}
+
 		// if a number key was pressed
 		if( '0' <= vk && vk <= '9' )
 		{
@@ -630,11 +644,16 @@ BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
 			break;
 
 		case VK_F3:
-			int nItem = GetCaret();
-				GetItemPosition( nItem, &m_Popup.m_Pos );
-				ClientToScreen( &m_Popup.m_Pos );
-//				GetClientRect( &m_Popup.m_TI.rect ); // put tooltip to the left of the item
+			{
+				int nItem = GetCaret();
+				CRect rc;
+				GetItemRect(nItem, rc, LVIR_BOUNDS);
+				ClientToScreen(rc);
+				m_Popup.m_Pos = CPoint(rc.left, rc.bottom);
 				m_Popup.Show( GetToolTipText(nItem) );
+			
+				break;
+			}
 		} // end switch(vk)
 
 		break; // end case WM_KEYDOWN