summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2010-12-20 07:48:59 +0000
committerGreg Ercolano <erco@seriss.com>2010-12-20 07:48:59 +0000
commit4a883a2e81164358f960f13d42fce599f38df5bc (patch)
treed3a5bd32126c20bd5ba4c137999427dcee7deefc
parentdf6de286e7421062372c468b6dca426c254ef379 (diff)
Added new tab_nav() control for Fl_Multiline_Input tab navigation behavior.
New default behavior is what most users expect; hitting Tab navigates over the widget. Fl_Input modified to support the new flag. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8068 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Input_.H42
-rw-r--r--FL/Fl_Multiline_Input.H5
-rw-r--r--src/Fl_Input.cxx4
-rw-r--r--src/Fl_Input_.cxx1
4 files changed, 50 insertions, 2 deletions
diff --git a/FL/Fl_Input_.H b/FL/Fl_Input_.H
index 766895668..f508117b9 100644
--- a/FL/Fl_Input_.H
+++ b/FL/Fl_Input_.H
@@ -120,6 +120,11 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
\p mark_, no text is selected */
int mark_;
+ /** \internal Behavior of Tab key in multiline input widget.
+ If enabled (default) Tab causes focus nav, otherwise Tab is inserted
+ as a character. */
+ int tab_nav_;
+
/** \internal Offset to text origin within widget bounds */
int xscroll_, yscroll_;
@@ -446,6 +451,43 @@ public:
void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP));
else type((uchar)(type() & ~FL_INPUT_WRAP)); }
+ /**
+ Sets whether the Tab key does focus navigation,
+ or inserts tab characters into Fl_Multiline_Input.
+
+ By default this flag is enabled to provide the 'normal' behavior
+ most users expect; Tab navigates focus to the next widget.
+ To inserting an actual Tab character, users can use Ctrl-I
+ or copy/paste.
+
+ Disabling this flag gives the old FLTK behavior where Tab
+ inserts a tab character into the text field, in which case
+ only the mouse can be used to navigate to the next field.
+
+ History: This flag was provided for backwards support of FLTK's old 1.1.x
+ behavior where Tab inserts a tab character instead of navigating
+ focus to the next widget. This behavior was unique to Fl_Multiline_Input.
+ With the advent of Fl_Text_Editor, this old behavior has been deprecated.
+
+ \param [in] val If \p val is 1, Tab advances focus (default).<BR>
+ If \p val is 0, Tab inserts a tab character (old FLTK behavior).
+ */
+ void tab_nav(int val) {
+ tab_nav_ = val;
+ }
+
+ /**
+ Gets whether the Tab key causes focus navigation in multiline input fields or not.
+
+ If enabled (default), hitting Tab causes focus navigation to the next widget.
+
+ If disabled, hitting Tab inserts a tab character into the text field.
+ \returns 1 if Tab advances focus (default), 0 if Tab inserts tab characters.
+ \see tab_nav(int)
+ */
+ int tab_nav() const {
+ return tab_nav_;
+ }
};
#endif
diff --git a/FL/Fl_Multiline_Input.H b/FL/Fl_Multiline_Input.H
index 8566063df..2657d6db2 100644
--- a/FL/Fl_Multiline_Input.H
+++ b/FL/Fl_Multiline_Input.H
@@ -46,6 +46,11 @@
If you are presenting large amounts of text and need scrollbars
or full color control of characters, you probably want Fl_Text_Editor
instead.
+
+ In FLTK 1.3.x, the default behavior of the 'Tab' key was changed
+ to support consistent focus navigation. To get the older FLTK 1.1.x
+ behavior, set Fl_Input_::tab_nav() to 0. Newer programs should consider using
+ Fl_Text_Editor.
*/
class FL_EXPORT Fl_Multiline_Input : public Fl_Input {
public:
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index b0d656e2c..d0e897a21 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -538,7 +538,7 @@ int Fl_Input::handle_key() {
// tab handled as a normal insertable character.
//
if (mods==0 && !shift // Tab?
- //// PROPOSED && !tab_nav() // old tab behavior enabled?
+ && !tab_nav() // old tab behavior enabled?
&& multiline) { // multiline input?
break; // insert tab character
}
@@ -614,7 +614,7 @@ int Fl_Input::handle(int event) {
//
if (Fl::event_key() == FL_Tab // Tab key?
&& !Fl::event_state(FL_SHIFT) // no shift?
- //// PROPOSED && !tab_nav() // with tab navigation disabled?
+ && !tab_nav() // with tab navigation disabled?
&& input_type() == FL_MULTILINE_INPUT // with a multiline input?
&& (mark()==0 && position()==size())) { // while entire field selected?
// Set cursor to the end of the selection...
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index a0438356c..2c4e5336c 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -1059,6 +1059,7 @@ Fl_Input_::Fl_Input_(int X, int Y, int W, int H, const char* l)
maximum_size_ = 32767;
shortcut_ = 0;
set_flag(SHORTCUT_LABEL);
+ tab_nav(1);
}
/**