summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2016-07-19 20:18:18 +0000
committerGreg Ercolano <erco@seriss.com>2016-07-19 20:18:18 +0000
commitdfd97e46397868e302c659dba71ade45e69468ed (patch)
tree68f6a1b3f4a17b6fc3ef064c1f681bb1036377b3
parentdc8a00fbba213c9ea8632c046230ecc677b996f9 (diff)
Bringing over this fix from 1.3 current to the porting branch.
Fixes STR #3305; adds tab_nav() method allowing Fl_Text_Editor to honor tab key focus navigation. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11820 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Text_Editor.H5
-rw-r--r--src/Fl_Text_Editor.cxx51
2 files changed, 56 insertions, 0 deletions
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).<br>
+ 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$".
//