diff --git a/FL/Fl_Text_Editor.H b/FL/Fl_Text_Editor.H index 1a01dfc8d..4e6eb52d6 100644 --- a/FL/Fl_Text_Editor.H +++ b/FL/Fl_Text_Editor.H @@ -66,6 +66,11 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { */ int insert_mode() { return insert_mode_; } +#if FLTK_ABI_VERSION >= 10304 + void tab_nav(int val); + int tab_nav() const; +#endif + void add_key_binding(int key, int state, Key_Func f, Key_Binding** list); /** Adds a \p key of state \p state with the function \p f. */ void add_key_binding(int key, int state, Key_Func f) diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index b2ec38456..04c9c68e7 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -660,6 +660,57 @@ int Fl_Text_Editor::handle(int event) { return Fl_Text_Display::handle(event); } +#if FLTK_ABI_VERSION >= 10304 +/** +Enables or disables Tab key focus navigation. + +When disabled (default), tab characters are inserted into +Fl_Text_Editor. Only the mouse can change focus. This behavior is +desireable when Fl_Text_Editor is used, e.g. in a source code editor. + +When enabled, Tab navigates focus to the next widget, and Shift-Tab +navigates focus to the previous widget. This behavior is desireable +when Fl_Text_Editor is used e.g. in a database input form. + +Currently, this method is implemented as a convenience method +that adjusts the key bindings for the Tab key. This implementation +detail may change in the future. Know that changing the editor's +key bindings for Tab and Shift-Tab may affect tab navigation. + +\param [in] val If \p val is 0, Tab inserts a tab character (default).
+ If \p val is 1, Tab navigates widget focus. + +\see tab_nav(), Fl::OPTION_ARROW_FOCUS. +\version 1.3.4 ABI feature +*/ +void Fl_Text_Editor::tab_nav(int val) { + if ( val ) + add_key_binding(FL_Tab, 0, kf_ignore); + else + remove_key_binding(FL_Tab, 0); +} + +/** +Check if Tab focus navigation is enabled. + +If disabled (default), hitting Tab inserts a tab character into the +editor buffer. + +If enabled, hitting Tab navigates focus to the next widget, +and Shift-Tab navigates focus to the previous widget. + +\returns if Tab inserts tab characters or moves the focus +\retval 0 Tab inserts tab characters (default) +\retval 1 Tab navigation is enabled. + +\see tab_nav(int), Fl::OPTION_ARROW_FOCUS. +\version 1.3.4 ABI feature +*/ +int Fl_Text_Editor::tab_nav() const { + return (bound_key_function(FL_Tab,0)==kf_ignore) ? 1 : 0; +} +#endif + // // End of "$Id$". //