From a768c335574e1db3c739aaab1ad0c9be3b2cb598 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sun, 29 Dec 2013 03:22:24 +0000 Subject: [PATCH] Add the ability to show a CallTip in the stc sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75455 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/stc/edit.cpp | 18 ++++++++++++++++++ samples/stc/edit.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index 8d24658422..d3b4349f08 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -112,6 +112,8 @@ BEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl) EVT_STC_MARGINCLICK (wxID_ANY, Edit::OnMarginClick) EVT_STC_CHARADDED (wxID_ANY, Edit::OnCharAdded) EVT_STC_KEY( wxID_ANY , Edit::OnKey ) + + EVT_KEY_DOWN( Edit::OnKeyDown ) END_EVENT_TABLE() Edit::Edit (wxWindow *parent, wxWindowID id, @@ -210,6 +212,22 @@ void Edit::OnKey (wxStyledTextEvent &WXUNUSED(event)) wxMessageBox("OnKey"); } +void Edit::OnKeyDown (wxKeyEvent &event) +{ + if (CallTipActive()) + CallTipCancel(); + if (event.GetKeyCode() == WXK_SPACE && event.ControlDown() && event.ShiftDown()) + { + int pos = GetCurrentPos(); + CallTipSetBackground(*wxYELLOW); + CallTipShow(pos, + "This is a CallTip with multiple lines.\n" + "It is meant to be a context sensitive popup helper for the user."); + return; + } + event.Skip(); +} + void Edit::OnEditCut (wxCommandEvent &WXUNUSED(event)) { if (GetReadOnly() || (GetSelectionEnd()-GetSelectionStart() <= 0)) return; Cut (); diff --git a/samples/stc/edit.h b/samples/stc/edit.h index 7c23268fba..926fe3c8df 100644 --- a/samples/stc/edit.h +++ b/samples/stc/edit.h @@ -103,6 +103,8 @@ public: void OnCharAdded (wxStyledTextEvent &event); void OnKey (wxStyledTextEvent &event); + void OnKeyDown(wxKeyEvent &event); + //! language/lexer wxString DeterminePrefs (const wxString &filename); bool InitializePrefs (const wxString &filename);