formatting.
- Support for loading TGA files added (Seth Jackson)
- Added wxTB_RIGHT style for right-aligned toolbars (Igor Korot)
-- Added events API to wxHtmlWindow (Francesco Montorsi).
+- wxHtmlWindow now generates events on link clicks (Francesco Montorsi).
+- wxHtmlWindow now also generates wxEVT_COMMAND_TEXT_COPY event
Unix Ports:
void OnKeyUp(wxKeyEvent& event);
void OnDoubleClick(wxMouseEvent& event);
void OnCopy(wxCommandEvent& event);
+ void OnClipboardEvent(wxClipboardTextEvent& event);
void OnMouseEnter(wxMouseEvent& event);
void OnMouseLeave(wxMouseEvent& event);
void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
#include "wx/fs_inet.h"
#include "wx/filedlg.h"
#include "wx/utils.h"
+#include "wx/clipbrd.h"
+#include "wx/dataobj.h"
#include "../../sample.xpm"
wxString *WXUNUSED(redirect)) const;
private:
+ void OnClipboardEvent(wxClipboardTextEvent& event);
+
+#if wxUSE_CLIPBOARD
+ DECLARE_EVENT_TABLE()
+#endif // wxUSE_CLIPBOARD
DECLARE_NO_COPY_CLASS(MyHtmlWindow)
};
GetRelatedFrame()->SetStatusText(url + _T(" lately opened"),1);
return wxHTML_OPEN;
}
+
+#if wxUSE_CLIPBOARD
+BEGIN_EVENT_TABLE(MyHtmlWindow, wxHtmlWindow)
+ EVT_TEXT_COPY(wxID_ANY, MyHtmlWindow::OnClipboardEvent)
+END_EVENT_TABLE()
+
+void MyHtmlWindow::OnClipboardEvent(wxClipboardTextEvent& WXUNUSED(event))
+{
+ // explicitly call wxHtmlWindow::CopySelection() method
+ // and show the first 100 characters of the text copied in the status bar
+ if ( CopySelection() )
+ {
+ wxTextDataObject data;
+ if ( wxTheClipboard && wxTheClipboard->GetData(data) )
+ {
+ const wxString text = data.GetText();
+ const size_t maxTextLength = 100;
+
+ wxLogStatus(wxString::Format(_T("Clipboard: '%s%s'"),
+ wxString(text, maxTextLength).c_str(),
+ (text.length() > maxTextLength) ? _T("...")
+ : _T("")));
+ return;
+ }
+ }
+
+ wxLogStatus(_T("Clipboard: nothing"));
+}
+#endif // wxUSE_CLIPBOARD
void wxHtmlWindow::OnKeyUp(wxKeyEvent& event)
{
- if ( IsSelectionEnabled() && event.GetKeyCode() == 'C' && event.CmdDown() )
+ if ( IsSelectionEnabled() &&
+ (event.GetKeyCode() == 'C' && event.CmdDown()) )
{
- (void) CopySelection();
+ wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId());
+
+ evt.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(evt);
}
}
(void) CopySelection();
}
+void wxHtmlWindow::OnClipboardEvent(wxClipboardTextEvent& WXUNUSED(event))
+{
+ (void) CopySelection();
+}
+
void wxHtmlWindow::OnDoubleClick(wxMouseEvent& event)
{
// select word under cursor:
EVT_MOUSE_CAPTURE_LOST(wxHtmlWindow::OnMouseCaptureLost)
EVT_KEY_UP(wxHtmlWindow::OnKeyUp)
EVT_MENU(wxID_COPY, wxHtmlWindow::OnCopy)
+ EVT_TEXT_COPY(wxID_ANY, wxHtmlWindow::OnClipboardEvent)
#endif // wxUSE_CLIPBOARD
END_EVENT_TABLE()