I don't know if this is helpful or not, but here's a patch to add a very rudimentary type of autocompletion to the wxWidgets stc sample. It doesn't show the crash under discussion, so it might not be helpful at all.
diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp
index 7e7f412ec2..c16b1aae2b 100644
--- a/samples/stc/edit.cpp
+++ b/samples/stc/edit.cpp
@@ -60,6 +60,21 @@ const int ANNOTATION_STYLE = wxSTC_STYLE_LASTPREDEFINED + 1;
// Edit
//----------------------------------------------------------------------------
+static char * pound_xpm[] = {
+"10 10 2 1",
+" c None",
+". c #BD08F9",
+" .. .. ",
+" .. .. ",
+"..........",
+"..........",
+" .. .. ",
+" .. .. ",
+"..........",
+"..........",
+" .. .. ",
+" .. .. "};
+
wxBEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl)
// common
EVT_SIZE ( Edit::OnSize)
@@ -177,6 +192,10 @@ Edit::Edit (wxWindow *parent, wxWindowID id,
CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key
SetLayoutCache (wxSTC_CACHE_PAGE);
UsePopUp(wxSTC_POPUP_ALL);
+
+ wxImage::AddHandler(new wxXPMHandler);
+ wxBitmap b(pound_xpm);
+ RegisterImage(0, b);
}
Edit::~Edit () {}
@@ -483,6 +502,13 @@ void Edit::OnCharAdded (wxStyledTextEvent &event) {
SetLineIndentation (currentLine, lineInd);
GotoPos(PositionFromLine (currentLine) + lineInd);
}
+ else if (chr == '#') {
+ wxString s = "define?0 elif?0 elifdef?0 elifndef?0 else?0 endif?0 "
+ "error?0 if?0 ifdef?0 ifndef?0 include?0 line?0 line?0 "
+ "pragma?0 undef?0";
+
+ AutoCompShow(0,s);
+ }
}
Hi, thanks for the contribution, I just test the stc sample with your patch.
The auto suggestion(auto completion) window shows correctly after I hit the "#", and I can keep typing in the editor, while the correct item is selected.
The issue I see is that if I "deactivate" the stcsample's main frame, the auto completion list is still active, which covers every active application's window.
The same effect can be achieved when we comment out the line:
void cbStyledTextCtrl::OnKillFocus(wxFocusEvent& event)
{
// cancel auto-completion list when losing focus
//if ( AutoCompActive() )
// AutoCompCancel();
if ( CallTipActive() )
CallTipCancel();
event.Skip();
}
With the above changes in sdk\cbstyledtextctrl.cpp, we can avoid the crash issue, but we get the same issue as the stc sample with your patch.