aboutsummaryrefslogtreecommitdiff
path: root/dw/fltkui.cc
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2011-06-18 13:54:11 -0400
committerJorge Arellano Cid <jcid@dillo.org>2011-06-18 13:54:11 -0400
commit72a39b9bfd045295e23ed387143c5783806ec993 (patch)
tree0e4fd7f33b8961fbcd490c5930d6b4fa34ccde16 /dw/fltkui.cc
parentcca34c9b9be61932c9129be668dbc24832703161 (diff)
Enabled CTRL+{a,e,d,k} shortcuts for form's inputs
Diffstat (limited to 'dw/fltkui.cc')
-rw-r--r--dw/fltkui.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index a2cab912..1f0422b2 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -36,6 +36,48 @@
#include <stdio.h>
+//----------------------------------------------------------------------------
+/*
+ * Local sub classes
+ */
+
+/*
+ * Used to enable CTRL+{a,e,d,k} in form inputs (for start,end,del,cut)
+ */
+class CustInput2 : public Fl_Input {
+public:
+ CustInput2 (int x, int y, int w, int h, const char* l=0) :
+ Fl_Input(x,y,w,h,l) {};
+ int handle(int e);
+};
+
+int CustInput2::handle(int e)
+{
+ int k = Fl::event_key();
+
+ _MSG("CustInput2::handle event=%d\n", e);
+
+ // We're only interested in some flags
+ unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
+
+ // Don't focus with arrow keys
+ if (e == FL_KEYBOARD && modifier == FL_CTRL) {
+ if (k == 'a' || k == 'e') {
+ position(k == 'a' ? 0 : size());
+ return 1;
+ } else if (k == 'k') {
+ cut(position(), size());
+ return 1;
+ } else if (k == 'd') {
+ cut(position(), position()+1);
+ return 1;
+ }
+ }
+ return Fl_Input::handle(e);
+}
+
+//----------------------------------------------------------------------------
+
namespace dw {
namespace fltk {
namespace ui {
@@ -449,7 +491,7 @@ Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation
*allocation)
{
Fl_Input *input =
- new Fl_Input (allocation->x, allocation->y, allocation->width,
+ new CustInput2(allocation->x, allocation->y, allocation->width,
allocation->ascent + allocation->descent);
if (password)
input->type(FL_SECRET_INPUT);