]> git.saurik.com Git - wxWidgets.git/commitdiff
doubleclick selects word
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 4 Jun 2003 21:42:34 +0000 (21:42 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 4 Jun 2003 21:42:34 +0000 (21:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/html/htmlwin.h
src/html/htmlwin.cpp

index 6a4e2fdf2ec48614d7e4973a10347970b7c80951..c94b2fa5208fdea71f547f6f961812bea18bfb1e 100644 (file)
@@ -217,6 +217,7 @@ protected:
     void OnIdle(wxIdleEvent& event);
 #if wxUSE_CLIPBOARD
     void OnKeyUp(wxKeyEvent& event);
+    void OnDoubleClick(wxMouseEvent& event);
     void OnCopy(wxCommandEvent& event);
     void OnMouseEnter(wxMouseEvent& event);
     void OnMouseLeave(wxMouseEvent& event);
index a31d540ccf873cdad70e01c10ad0718d50784747..1af6efb59dad9733f0ab5d9c2cfcefcc4a7b9823 100644 (file)
@@ -1018,13 +1018,15 @@ void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
                 {
                     SetCursor(*s_cur_arrow);
                     if (m_RelatedStatusBar != -1)
-                        m_RelatedFrame->SetStatusText(wxEmptyString, m_RelatedStatusBar);
+                        m_RelatedFrame->SetStatusText(wxEmptyString,
+                                                      m_RelatedStatusBar);
                 }
                 else
                 {
                     SetCursor(*s_cur_hand);
                     if (m_RelatedStatusBar != -1)
-                        m_RelatedFrame->SetStatusText(lnk->GetHref(), m_RelatedStatusBar);
+                        m_RelatedFrame->SetStatusText(lnk->GetHref(),
+                                                      m_RelatedStatusBar);
                 }
                 m_tmpLastLink = lnk;
             }
@@ -1123,13 +1125,12 @@ void wxHtmlWindow::OnMouseLeave(wxMouseEvent& event)
 
 void wxHtmlWindow::OnKeyUp(wxKeyEvent& event)
 {
-    if ( event.GetKeyCode() == 'C' && event.ControlDown() )
+    if ( IsSelectionEnabled() &&
+         event.GetKeyCode() == 'C' && event.ControlDown() )
     {
         if ( m_selection )
             CopySelection();
     }
-    else
-        event.Skip();
 }
 
 void wxHtmlWindow::OnCopy(wxCommandEvent& event)
@@ -1137,6 +1138,26 @@ void wxHtmlWindow::OnCopy(wxCommandEvent& event)
     if ( m_selection )
         CopySelection();
 }
+    
+void wxHtmlWindow::OnDoubleClick(wxMouseEvent& event)
+{
+    // select word under cursor:
+    if ( IsSelectionEnabled() )
+    {
+        wxPoint pos = CalcUnscrolledPosition(event.GetPosition());
+        wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y);
+        if ( cell )
+        {
+            delete m_selection;
+            m_selection = new wxHtmlSelection();
+            m_selection->Set(cell, cell);
+            RefreshRect(wxRect(CalcScrolledPosition(cell->GetAbsPos()),
+                               wxSize(cell->GetWidth(), cell->GetHeight())));
+        }
+    }
+    else
+        event.Skip();
+}
 #endif
 
 
@@ -1155,6 +1176,7 @@ BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
     EVT_ERASE_BACKGROUND(wxHtmlWindow::OnEraseBackground)
     EVT_PAINT(wxHtmlWindow::OnPaint)
 #if wxUSE_CLIPBOARD
+    EVT_LEFT_DCLICK(wxHtmlWindow::OnDoubleClick)
     EVT_ENTER_WINDOW(wxHtmlWindow::OnMouseEnter)
     EVT_LEAVE_WINDOW(wxHtmlWindow::OnMouseLeave)
     EVT_KEY_UP(wxHtmlWindow::OnKeyUp)