From f152cf5a84cfb348f3b1912bae4acff7002ff9ca Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Wed, 3 Nov 1999 15:55:14 +0000 Subject: [PATCH] A bit more testing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/text/text.cpp | 21 +++++++++++++++++++-- samples/toolbar/test.cpp | 9 ++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/samples/text/text.cpp b/samples/text/text.cpp index 4d26e23e96..ee6a8387ef 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -57,12 +57,14 @@ class MyTextCtrl : public wxTextCtrl public: MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, int style = 0) - : wxTextCtrl(parent, id, value, pos, size, style) { } + : wxTextCtrl(parent, id, value, pos, size, style) { m_hasCapture = FALSE; } void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); void OnChar(wxKeyEvent& event); + bool m_hasCapture; + private: static inline wxChar GetChar(bool on, wxChar c) { return on ? c : _T('-'); } void LogEvent(const wxChar *name, wxKeyEvent& event) const; @@ -411,6 +413,21 @@ void MyTextCtrl::OnKeyDown(wxKeyEvent& event) // go to position 10 SetInsertionPoint(10); break; + + case WXK_F4: + if (!m_hasCapture) + { + wxLogDebug( wxT("Now capturing mouse and events.") ); + m_hasCapture = TRUE; + CaptureMouse(); + } + else + { + wxLogDebug( wxT("Stopped capturing mouse and events.") ); + m_hasCapture = TRUE; + ReleaseMouse(); + } + break; } LogEvent( _("Key down"), event); @@ -463,7 +480,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_multitext->WriteText( "Prepended. " ); #if wxUSE_TOOLTIPS - m_multitext->SetToolTip("Press F1 here."); + m_multitext->SetToolTip("Press F1 here for statitics, F4 for capture and uncapture mouse."); #endif m_tab = new MyTextCtrl( this, -1, "Multiline, allow processing.", diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index ee3af9a57d..94d4b47df8 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -209,10 +209,10 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) if ( !smallicons ) { currentX += width + 5; - toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save file"); + toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Disable/Enable print button"); + toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 2"); currentX += width + 5; toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Toggle/Untoggle help button"); currentX += width + 5; @@ -222,8 +222,11 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), *(toolBarBitmaps[6]), TRUE, currentX, -1, (wxObject *) NULL, "Help"); + toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help button"); + toolBar->ToggleTool( wxID_SAVE, TRUE ); + toolBar->ToggleTool( wxID_COPY, TRUE ); + toolBar->ToggleTool( wxID_COPY, FALSE ); toolBar->EnableTool( wxID_PRINT, FALSE ); } -- 2.45.2