Changed how EVT_CHAR and EVT_KEY_DOWN are sent to Scintilla
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
243d4b3603
commit
d6582821b6
@ -1593,6 +1593,7 @@ private:
|
||||
ScintillaWX* m_swx;
|
||||
wxStopWatch m_stopWatch;
|
||||
|
||||
bool m_lastKeyDownConsumed;
|
||||
|
||||
friend class ScintillaWX;
|
||||
friend class Platform;
|
||||
|
@ -49,7 +49,6 @@ public:
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnStyleNeeded(wxStyledTextEvent& event);
|
||||
|
||||
private:
|
||||
wxStyledTextCtrl* ed;
|
||||
@ -70,7 +69,6 @@ enum
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU (ID_Quit, MyFrame::OnQuit)
|
||||
EVT_MENU (ID_About, MyFrame::OnAbout)
|
||||
EVT_STC_STYLENEEDED (ID_ED, MyFrame::OnStyleNeeded)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
@ -181,14 +179,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
|
||||
// event handlers
|
||||
|
||||
void MyFrame::OnStyleNeeded(wxStyledTextEvent& event) {
|
||||
int currEndStyled = ed->GetEndStyled();
|
||||
ed->Colourise(currEndStyled, event.GetPosition());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
// TRUE is to force the frame to close
|
||||
|
@ -429,29 +429,40 @@ void ScintillaWX::DoAddChar(char ch) {
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
|
||||
switch (key) {
|
||||
case WXK_DOWN: key = SCK_DOWN; break;
|
||||
case WXK_UP: key = SCK_UP; break;
|
||||
case WXK_LEFT: key = SCK_LEFT; break;
|
||||
case WXK_RIGHT: key = SCK_RIGHT; break;
|
||||
case WXK_HOME: key = SCK_HOME; break;
|
||||
case WXK_END: key = SCK_END; break;
|
||||
case WXK_PRIOR: key = SCK_PRIOR; break;
|
||||
case WXK_NEXT: key = SCK_NEXT; break;
|
||||
case WXK_DELETE: key = SCK_DELETE; break;
|
||||
case WXK_INSERT: key = SCK_INSERT; break;
|
||||
case WXK_ESCAPE: key = SCK_ESCAPE; break;
|
||||
case WXK_BACK: key = SCK_BACK; break;
|
||||
case WXK_TAB: key = SCK_TAB; break;
|
||||
case WXK_RETURN: key = SCK_RETURN; break;
|
||||
case WXK_ADD: key = SCK_ADD; break;
|
||||
case WXK_SUBTRACT: key = SCK_SUBTRACT; break;
|
||||
case WXK_DIVIDE: key = SCK_DIVIDE; break;
|
||||
case WXK_CONTROL: key = 0; break;
|
||||
case WXK_ALT: key = 0; break;
|
||||
case WXK_SHIFT: key = 0; break;
|
||||
case WXK_DOWN: key = SCK_DOWN; break;
|
||||
case WXK_UP: key = SCK_UP; break;
|
||||
case WXK_LEFT: key = SCK_LEFT; break;
|
||||
case WXK_RIGHT: key = SCK_RIGHT; break;
|
||||
case WXK_HOME: key = SCK_HOME; break;
|
||||
case WXK_END: key = SCK_END; break;
|
||||
case WXK_PRIOR: key = SCK_PRIOR; break;
|
||||
case WXK_NEXT: key = SCK_NEXT; break;
|
||||
case WXK_DELETE: key = SCK_DELETE; break;
|
||||
case WXK_INSERT: key = SCK_INSERT; break;
|
||||
case WXK_ESCAPE: key = SCK_ESCAPE; break;
|
||||
case WXK_BACK: key = SCK_BACK; break;
|
||||
case WXK_TAB: key = SCK_TAB; break;
|
||||
case WXK_RETURN: key = SCK_RETURN; break;
|
||||
case WXK_ADD:
|
||||
case WXK_NUMPAD_ADD:
|
||||
key = SCK_ADD; break;
|
||||
case WXK_SUBTRACT:
|
||||
case WXK_NUMPAD_SUBTRACT:
|
||||
key = SCK_SUBTRACT; break;
|
||||
case WXK_DIVIDE:
|
||||
case WXK_NUMPAD_DIVIDE:
|
||||
key = SCK_DIVIDE; break;
|
||||
case WXK_CONTROL: key = 0; break;
|
||||
case WXK_ALT: key = 0; break;
|
||||
case WXK_SHIFT: key = 0; break;
|
||||
case WXK_MENU: key = 0; break;
|
||||
}
|
||||
|
||||
return KeyDown(key, shift, ctrl, alt, consumed);
|
||||
int rv = KeyDown(key, shift, ctrl, alt, consumed);
|
||||
if (key)
|
||||
return rv;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,6 +137,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
{
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
m_lastKeyDownConsumed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -1833,42 +1834,39 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
|
||||
|
||||
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
if ((key > WXK_ESCAPE) &&
|
||||
(key != WXK_DELETE) && (key < 255) &&
|
||||
!evt.ControlDown() && !evt.AltDown()) {
|
||||
|
||||
if (key <= 0xff && !iscntrl(key) && !m_lastKeyDownConsumed) {
|
||||
m_swx->DoAddChar(key);
|
||||
}
|
||||
else {
|
||||
evt.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
//key = toupper(key); //**** ????
|
||||
bool consumed = FALSE;
|
||||
int processed = m_swx->DoKeyDown(key,
|
||||
evt.ShiftDown(),
|
||||
evt.ControlDown(),
|
||||
evt.AltDown(),
|
||||
&consumed);
|
||||
if (!processed && !consumed)
|
||||
&m_lastKeyDownConsumed);
|
||||
if (!processed && !m_lastKeyDownConsumed)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
@ -137,6 +137,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
{
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
m_lastKeyDownConsumed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -379,42 +380,39 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
|
||||
|
||||
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
if ((key > WXK_ESCAPE) &&
|
||||
(key != WXK_DELETE) && (key < 255) &&
|
||||
!evt.ControlDown() && !evt.AltDown()) {
|
||||
|
||||
if (key <= 0xff && !iscntrl(key) && !m_lastKeyDownConsumed) {
|
||||
m_swx->DoAddChar(key);
|
||||
}
|
||||
else {
|
||||
evt.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
//key = toupper(key); //**** ????
|
||||
bool consumed = FALSE;
|
||||
int processed = m_swx->DoKeyDown(key,
|
||||
evt.ShiftDown(),
|
||||
evt.ControlDown(),
|
||||
evt.AltDown(),
|
||||
&consumed);
|
||||
if (!processed && !consumed)
|
||||
&m_lastKeyDownConsumed);
|
||||
if (!processed && !m_lastKeyDownConsumed)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ private:
|
||||
ScintillaWX* m_swx;
|
||||
wxStopWatch m_stopWatch;
|
||||
|
||||
bool m_lastKeyDownConsumed;
|
||||
|
||||
friend class ScintillaWX;
|
||||
friend class Platform;
|
||||
|
@ -1593,6 +1593,7 @@ private:
|
||||
ScintillaWX* m_swx;
|
||||
wxStopWatch m_stopWatch;
|
||||
|
||||
bool m_lastKeyDownConsumed;
|
||||
|
||||
friend class ScintillaWX;
|
||||
friend class Platform;
|
||||
|
@ -49,7 +49,6 @@ public:
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnStyleNeeded(wxStyledTextEvent& event);
|
||||
|
||||
private:
|
||||
wxStyledTextCtrl* ed;
|
||||
@ -70,7 +69,6 @@ enum
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU (ID_Quit, MyFrame::OnQuit)
|
||||
EVT_MENU (ID_About, MyFrame::OnAbout)
|
||||
EVT_STC_STYLENEEDED (ID_ED, MyFrame::OnStyleNeeded)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
@ -181,14 +179,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
|
||||
// event handlers
|
||||
|
||||
void MyFrame::OnStyleNeeded(wxStyledTextEvent& event) {
|
||||
int currEndStyled = ed->GetEndStyled();
|
||||
ed->Colourise(currEndStyled, event.GetPosition());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
// TRUE is to force the frame to close
|
||||
|
@ -429,29 +429,40 @@ void ScintillaWX::DoAddChar(char ch) {
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
|
||||
switch (key) {
|
||||
case WXK_DOWN: key = SCK_DOWN; break;
|
||||
case WXK_UP: key = SCK_UP; break;
|
||||
case WXK_LEFT: key = SCK_LEFT; break;
|
||||
case WXK_RIGHT: key = SCK_RIGHT; break;
|
||||
case WXK_HOME: key = SCK_HOME; break;
|
||||
case WXK_END: key = SCK_END; break;
|
||||
case WXK_PRIOR: key = SCK_PRIOR; break;
|
||||
case WXK_NEXT: key = SCK_NEXT; break;
|
||||
case WXK_DELETE: key = SCK_DELETE; break;
|
||||
case WXK_INSERT: key = SCK_INSERT; break;
|
||||
case WXK_ESCAPE: key = SCK_ESCAPE; break;
|
||||
case WXK_BACK: key = SCK_BACK; break;
|
||||
case WXK_TAB: key = SCK_TAB; break;
|
||||
case WXK_RETURN: key = SCK_RETURN; break;
|
||||
case WXK_ADD: key = SCK_ADD; break;
|
||||
case WXK_SUBTRACT: key = SCK_SUBTRACT; break;
|
||||
case WXK_DIVIDE: key = SCK_DIVIDE; break;
|
||||
case WXK_CONTROL: key = 0; break;
|
||||
case WXK_ALT: key = 0; break;
|
||||
case WXK_SHIFT: key = 0; break;
|
||||
case WXK_DOWN: key = SCK_DOWN; break;
|
||||
case WXK_UP: key = SCK_UP; break;
|
||||
case WXK_LEFT: key = SCK_LEFT; break;
|
||||
case WXK_RIGHT: key = SCK_RIGHT; break;
|
||||
case WXK_HOME: key = SCK_HOME; break;
|
||||
case WXK_END: key = SCK_END; break;
|
||||
case WXK_PRIOR: key = SCK_PRIOR; break;
|
||||
case WXK_NEXT: key = SCK_NEXT; break;
|
||||
case WXK_DELETE: key = SCK_DELETE; break;
|
||||
case WXK_INSERT: key = SCK_INSERT; break;
|
||||
case WXK_ESCAPE: key = SCK_ESCAPE; break;
|
||||
case WXK_BACK: key = SCK_BACK; break;
|
||||
case WXK_TAB: key = SCK_TAB; break;
|
||||
case WXK_RETURN: key = SCK_RETURN; break;
|
||||
case WXK_ADD:
|
||||
case WXK_NUMPAD_ADD:
|
||||
key = SCK_ADD; break;
|
||||
case WXK_SUBTRACT:
|
||||
case WXK_NUMPAD_SUBTRACT:
|
||||
key = SCK_SUBTRACT; break;
|
||||
case WXK_DIVIDE:
|
||||
case WXK_NUMPAD_DIVIDE:
|
||||
key = SCK_DIVIDE; break;
|
||||
case WXK_CONTROL: key = 0; break;
|
||||
case WXK_ALT: key = 0; break;
|
||||
case WXK_SHIFT: key = 0; break;
|
||||
case WXK_MENU: key = 0; break;
|
||||
}
|
||||
|
||||
return KeyDown(key, shift, ctrl, alt, consumed);
|
||||
int rv = KeyDown(key, shift, ctrl, alt, consumed);
|
||||
if (key)
|
||||
return rv;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,6 +137,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
{
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
m_lastKeyDownConsumed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -1833,42 +1834,39 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
|
||||
|
||||
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
if ((key > WXK_ESCAPE) &&
|
||||
(key != WXK_DELETE) && (key < 255) &&
|
||||
!evt.ControlDown() && !evt.AltDown()) {
|
||||
|
||||
if (key <= 0xff && !iscntrl(key) && !m_lastKeyDownConsumed) {
|
||||
m_swx->DoAddChar(key);
|
||||
}
|
||||
else {
|
||||
evt.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
//key = toupper(key); //**** ????
|
||||
bool consumed = FALSE;
|
||||
int processed = m_swx->DoKeyDown(key,
|
||||
evt.ShiftDown(),
|
||||
evt.ControlDown(),
|
||||
evt.AltDown(),
|
||||
&consumed);
|
||||
if (!processed && !consumed)
|
||||
&m_lastKeyDownConsumed);
|
||||
if (!processed && !m_lastKeyDownConsumed)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
@ -137,6 +137,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
|
||||
{
|
||||
m_swx = new ScintillaWX(this);
|
||||
m_stopWatch.Start();
|
||||
m_lastKeyDownConsumed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -379,42 +380,39 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
|
||||
|
||||
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
if ((key > WXK_ESCAPE) &&
|
||||
(key != WXK_DELETE) && (key < 255) &&
|
||||
!evt.ControlDown() && !evt.AltDown()) {
|
||||
|
||||
if (key <= 0xff && !iscntrl(key) && !m_lastKeyDownConsumed) {
|
||||
m_swx->DoAddChar(key);
|
||||
}
|
||||
else {
|
||||
evt.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
|
||||
long key = evt.KeyCode();
|
||||
//key = toupper(key); //**** ????
|
||||
bool consumed = FALSE;
|
||||
int processed = m_swx->DoKeyDown(key,
|
||||
evt.ShiftDown(),
|
||||
evt.ControlDown(),
|
||||
evt.AltDown(),
|
||||
&consumed);
|
||||
if (!processed && !consumed)
|
||||
&m_lastKeyDownConsumed);
|
||||
if (!processed && !m_lastKeyDownConsumed)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoLoseFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
|
||||
m_swx->DoGainFocus();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
|
||||
m_swx->DoSysColourChange();
|
||||
}
|
||||
|
||||
|
||||
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
|
||||
// do nothing to help avoid flashing
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ private:
|
||||
ScintillaWX* m_swx;
|
||||
wxStopWatch m_stopWatch;
|
||||
|
||||
bool m_lastKeyDownConsumed;
|
||||
|
||||
friend class ScintillaWX;
|
||||
friend class Platform;
|
||||
|
Loading…
Reference in New Issue
Block a user