From 1da4efa50a5b989115292ea66befea52c73b8b2d Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 30 Sep 2013 14:32:42 +1000 Subject: Added FocusIn and FocusOut notification events (SCN_FOCUSIN/SCN_FOCUSOUT) to be used in preference to the SCEN_SETFOCUS and SCEN_KILLFOCUS command events. --- cocoa/ScintillaCocoa.mm | 2 ++ doc/ScintillaDoc.html | 13 +++++++++++-- gtk/ScintillaGTK.cxx | 1 + include/Scintilla.h | 2 ++ include/Scintilla.iface | 2 ++ qt/ScintillaEditBase/ScintillaQt.cpp | 2 ++ src/Editor.cxx | 6 +++++- win32/ScintillaWin.cxx | 1 + 8 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index ce1042e9b..79332eda6 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1708,6 +1708,8 @@ void ScintillaCocoa::NotifyFocus(bool focus) (uintptr_t) this); if (delegateHasCommand) [delegate command:(focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS) idFrom:GetCtrlID()]; + + Editor::NotifyFocus(focus); } //-------------------------------------------------------------------------------------------------- diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index d2be3b3e1..031fc0f72 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -6521,6 +6521,8 @@ struct SCNotification { SCN_AUTOCSELECTION
SCN_AUTOCCANCELLED
SCN_AUTOCCHARDELETED
+ SCN_FOCUSIN
+ SCN_FOCUSOUT

The following SCI_* messages are associated with these notifications:

@@ -6532,8 +6534,10 @@ struct SCNotification { SCI_GETIDENTIFIER
-

The following additional notifications are sent using the WM_COMMAND message on - Windows. +

The following additional notifications are sent using a secondary "command" method and should + be avoided in new code as the primary "notification" method provides all the same events with richer + information. + The WM_COMMAND message is used on Windows. This emulates the Windows Edit control. Only the lower 16 bits of the control's ID is passed in these notifications.

On GTK+, the "command" signal is sent and the signal handler should have the signature @@ -7275,6 +7279,11 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next The user deleted a character while autocompletion list was active. There is no other information in SCNotification.

+

SCN_FOCUSIN
+ SCN_FOCUSOUT
+ SCN_FOCUSIN (2028) is fired when Scintilla receives focus and + SCN_FOCUSOUT (2029) when it loses focus.

+

Images

Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.

diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 273333465..91c1250fc 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1208,6 +1208,7 @@ void ScintillaGTK::NotifyFocus(bool focus) { g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0, Platform::LongFromTwoShorts (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain)); + Editor::NotifyFocus(focus); } void ScintillaGTK::NotifyParent(SCNotification scn) { diff --git a/include/Scintilla.h b/include/Scintilla.h index 720ef21fc..b50d20260 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -987,6 +987,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_AUTOCCANCELLED 2025 #define SCN_AUTOCCHARDELETED 2026 #define SCN_HOTSPOTRELEASECLICK 2027 +#define SCN_FOCUSIN 2028 +#define SCN_FOCUSOUT 2029 #ifndef SCI_DISABLE_PROVISIONAL #define SC_LINE_END_TYPE_DEFAULT 0 #define SC_LINE_END_TYPE_UNICODE 1 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index b3e34ac3b..a49af7c69 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -4371,6 +4371,8 @@ evt void IndicatorRelease=2024(int modifiers, int position) evt void AutoCCancelled=2025(void) evt void AutoCCharDeleted=2026(void) evt void HotSpotReleaseClick=2027(int modifiers, int position) +evt void FocusIn=2028(void) +evt void FocusOut=2029(void) cat Provisional diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp index d79fe3a86..2e3b9a0a5 100644 --- a/qt/ScintillaEditBase/ScintillaQt.cpp +++ b/qt/ScintillaEditBase/ScintillaQt.cpp @@ -392,6 +392,8 @@ void ScintillaQt::NotifyFocus(bool focus) Platform::LongFromTwoShorts (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), reinterpret_cast(wMain.GetID())); + + Editor::NotifyFocus(focus); } void ScintillaQt::NotifyParent(SCNotification scn) diff --git a/src/Editor.cxx b/src/Editor.cxx index c990af34b..8fda6b9ba 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4414,7 +4414,11 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { ShowCaretAtCurrentPosition(); } -void Editor::NotifyFocus(bool) {} +void Editor::NotifyFocus(bool focus) { + SCNotification scn = {}; + scn.nmhdr.code = focus ? SCN_FOCUSIN : SCN_FOCUSOUT; + NotifyParent(scn); +} void Editor::SetCtrlID(int identifier) { ctrlID = identifier; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 03106b769..2ddc3944f 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -1429,6 +1429,7 @@ void ScintillaWin::NotifyFocus(bool focus) { ::SendMessage(::GetParent(MainHWND()), WM_COMMAND, MAKELONG(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), reinterpret_cast(MainHWND())); + Editor::NotifyFocus(focus); } void ScintillaWin::SetCtrlID(int identifier) { -- cgit v1.2.3