summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2022-01-13 15:26:27 -0800
committerGreg Ercolano <erco@seriss.com>2022-01-13 15:26:27 -0800
commit9c55ad4273ff3e4327daaaf28fc06bf6bbd4a645 (patch)
tree4e94c898bace2cc97f8623f454c68bb04966a789
parent47cd9a11a0d68fa511cb6c593b62b25af1550e19 (diff)
Fixes #362
-rw-r--r--FL/Fl_Input_Choice.H2
-rw-r--r--documentation/src/input_choice.jpgbin14814 -> 0 bytes
-rw-r--r--documentation/src/input_choice.pngbin0 -> 16484 bytes
-rw-r--r--src/Fl_Input_Choice.cxx54
4 files changed, 54 insertions, 2 deletions
diff --git a/FL/Fl_Input_Choice.H b/FL/Fl_Input_Choice.H
index 56fdd103a..c02195be7 100644
--- a/FL/Fl_Input_Choice.H
+++ b/FL/Fl_Input_Choice.H
@@ -45,8 +45,10 @@ class FL_EXPORT Fl_Input_Choice : public Fl_Group {
// Private class to handle slightly 'special' behavior of menu button
class InputMenuButton : public Fl_Menu_Button {
void draw();
+ const Fl_Menu_Item* popup();
public:
InputMenuButton(int X, int Y, int W, int H, const char *L=0);
+ int handle(int e);
};
Fl_Input *inp_;
diff --git a/documentation/src/input_choice.jpg b/documentation/src/input_choice.jpg
deleted file mode 100644
index 7600b1cd5..000000000
--- a/documentation/src/input_choice.jpg
+++ /dev/null
Binary files differ
diff --git a/documentation/src/input_choice.png b/documentation/src/input_choice.png
new file mode 100644
index 000000000..42cd6e74c
--- /dev/null
+++ b/documentation/src/input_choice.png
Binary files differ
diff --git a/src/Fl_Input_Choice.cxx b/src/Fl_Input_Choice.cxx
index bf52360f7..781e82277 100644
--- a/src/Fl_Input_Choice.cxx
+++ b/src/Fl_Input_Choice.cxx
@@ -32,8 +32,8 @@
\brief A combination of the input widget and a menu button.
- \image html input_choice.jpg
- \image latex input_choice.jpg "Fl_Input_Choice widget" width=6cm
+ \image html input_choice.png
+ \image latex input_choice.png "Fl_Input_Choice widget" width=6cm
The user can either type into the input area, or use the
menu button chooser on the right to choose an item which loads
@@ -142,6 +142,56 @@ void Fl_Input_Choice::InputMenuButton::draw() {
if (Fl::focus() == this) draw_focus();
}
+// Make pulldown menu appear under entire width of widget
+const Fl_Menu_Item* Fl_Input_Choice::InputMenuButton::popup() {
+ menu_end();
+ redraw();
+ Fl_Widget_Tracker mb(this);
+ // Make menu appear under entire width of Fl_Input_Choice parent group
+ const Fl_Menu_Item *m = menu()->pulldown(parent()->x(), y(), parent()->w(), h(), 0, this);
+ picked(m);
+ if (mb.exists()) redraw();
+ return m;
+}
+
+// Invokes our popup() method to ensure pulldown menu appears full width under widget
+// (This is the same handle() code in Fl_Menu_Button and Fl_Choice)
+//
+int Fl_Input_Choice::InputMenuButton::handle(int e) {
+ if (!menu() || !menu()->text) return 0;
+ switch (e) {
+ case FL_ENTER: /* FALLTHROUGH */
+ case FL_LEAVE:
+ return (box() && !type()) ? 1 : 0;
+ case FL_PUSH:
+ if (!box()) {
+ if (Fl::event_button() != 3) return 0;
+ } else if (type()) {
+ if (!(type() & (1 << (Fl::event_button()-1)))) return 0;
+ }
+ if (Fl::visible_focus()) Fl::focus(this);
+ popup();
+ return 1;
+ case FL_KEYBOARD:
+ if (!box()) return 0;
+ if (Fl::event_key() == ' ' &&
+ !(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) {
+ popup();
+ return 1;
+ } else return 0;
+ case FL_SHORTCUT:
+ if (Fl_Widget::test_shortcut()) {popup(); return 1;}
+ return test_shortcut() != 0;
+ case FL_FOCUS: /* FALLTHROUGH */
+ case FL_UNFOCUS:
+ if (box() && Fl::visible_focus()) {
+ redraw();
+ return 1;
+ }
+ default:
+ return 0;
+ }
+}
/** Callback for the Fl_Input_Choice menu. */