From: Václav Slavík Date: Wed, 4 Jun 2003 21:42:34 +0000 (+0000) Subject: doubleclick selects word X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/31eefb998d894e3b566e13714fa53186101829a1?ds=inline doubleclick selects word git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index 6a4e2fdf2e..c94b2fa520 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -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); diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index a31d540ccf..1af6efb59d 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -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)