aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/fltkcomplexbutton.cc3
-rw-r--r--dw/fltkui.cc22
-rw-r--r--src/dialog.cc24
3 files changed, 43 insertions, 6 deletions
diff --git a/dw/fltkcomplexbutton.cc b/dw/fltkcomplexbutton.cc
index 89295190..8f847218 100644
--- a/dw/fltkcomplexbutton.cc
+++ b/dw/fltkcomplexbutton.cc
@@ -108,7 +108,8 @@ int ComplexButton::handle(int event) {
return 1;
} else return 0;
case FL_KEYBOARD :
- if (Fl::focus() == this && Fl::event_key() == ' ' &&
+ if (Fl::focus() == this &&
+ (Fl::event_key() == ' ' || Fl::event_key() == FL_Enter) &&
!(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) {
set_changed();
Fl_Widget_Tracker wp(this);
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index c0c8ff42..66a96691 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -266,6 +266,24 @@ template <class I> void FltkSpecificResource<I>::setEnabled (bool enabled)
// ----------------------------------------------------------------------
+class EnterButton : public Fl_Button {
+public:
+ EnterButton (int x,int y,int w,int h, const char* label = 0) :
+ Fl_Button (x,y,w,h,label) {};
+ int handle(int e);
+};
+
+int EnterButton::handle(int e)
+{
+ if (e == FL_KEYBOARD && Fl::focus() == this && Fl::event_key() == FL_Enter){
+ set_changed();
+ simulate_key_action();
+ do_callback();
+ return 1;
+ }
+ return Fl_Button::handle(e);
+}
+
FltkLabelButtonResource::FltkLabelButtonResource (FltkPlatform *platform,
const char *label):
FltkSpecificResource <dw::core::ui::LabelButtonResource> (platform)
@@ -283,8 +301,8 @@ Fl_Widget *FltkLabelButtonResource::createNewWidget (core::Allocation
*allocation)
{
Fl_Button *button =
- new Fl_Button (allocation->x, allocation->y, allocation->width,
- allocation->ascent + allocation->descent, label);
+ new EnterButton (allocation->x, allocation->y, allocation->width,
+ allocation->ascent + allocation->descent, label);
button->callback (widgetCallback, this);
button->when (FL_WHEN_RELEASE);
return button;
diff --git a/src/dialog.cc b/src/dialog.cc
index 15e5d7a9..f830f2d3 100644
--- a/src/dialog.cc
+++ b/src/dialog.cc
@@ -95,6 +95,24 @@ public:
};
};
+class EnterButton : public Fl_Button {
+public:
+ EnterButton (int x,int y,int w,int h, const char* label = 0) :
+ Fl_Button (x,y,w,h,label) {};
+ int handle(int e);
+};
+
+int EnterButton::handle(int e)
+{
+ if (e == FL_KEYBOARD && Fl::focus() == this && Fl::event_key() == FL_Enter){
+ set_changed();
+ simulate_key_action();
+ do_callback();
+ return 1;
+ }
+ return Fl_Button::handle(e);
+}
+
//----------------------------------------------------------------------------
@@ -354,7 +372,7 @@ int a_Dialog_choice5(const char *QuestionTxt,
bw = (ww - gap)/nb - gap;
xpos += gap;
for (int i=1; i <= nb; ++i) {
- b = new Fl_Button(xpos, wh-bh, bw, bh, txt[i]);
+ b = new EnterButton(xpos, wh-bh, bw, bh, txt[i]);
b->align(FL_ALIGN_WRAP|FL_ALIGN_CLIP);
b->box(FL_UP_BOX);
b->callback(choice5_cb, INT2VOIDP(i));
@@ -426,14 +444,14 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp)
/* "OK" button */
y += input_h + 20;
- Fl_Button *ok_button = new Fl_Button(200, y, 50, button_h, "OK");
+ Fl_Button *ok_button = new EnterButton(200, y, 50, button_h, "OK");
ok_button->labelsize(14);
ok_button->callback(Dialog_user_password_cb);
window->add(ok_button);
/* "Cancel" button */
Fl_Button *cancel_button =
- new Fl_Button(50, y, 100, button_h, "Cancel");
+ new EnterButton(50, y, 100, button_h, "Cancel");
cancel_button->labelsize(14);
cancel_button->callback(Dialog_user_password_cb);
window->add(cancel_button);