changeset 1790:45b10f359e51

keys and mouse buttons
author corvid <corvid@lavabit.com>
date Thu, 06 Jan 2011 02:15:06 +0000
parents a1cd7f0155b6
children 8a5a07c67265
files dw/fltkui.cc dw/fltkviewport.cc src/findbar.cc src/keys.cc src/menu.cc src/ui.cc src/uicmd.cc
diffstat 7 files changed, 114 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkui.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/dw/fltkui.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -316,9 +316,9 @@
                                               void *data)
 {
    if ((widget->when () & ::fltk::WHEN_RELEASE) &&
-       ((::fltk::event_key() == ::fltk::ReturnKey) ||
-        (::fltk::event_button() == ::fltk::LeftButton ||
-         ::fltk::event_button() == ::fltk::MiddleButton))) {
+       ((::fltk::event_key() == FL_Enter) ||
+        (::fltk::event_button() == FL_LEFT_MOUSE ||
+         ::fltk::event_button() == FL_MIDDLE_MOUSE))) {
       FltkLabelButtonResource *lbr = (FltkLabelButtonResource*) data;
       dw::core::EventButton event;
       setButtonEvent(&event);
@@ -364,9 +364,9 @@
    FltkComplexButtonResource *res = (FltkComplexButtonResource*)data;
 
    if (widget->when() == ::fltk::WHEN_RELEASE &&
-       ((::fltk::event_key() == ::fltk::ReturnKey) ||
-        (::fltk::event_button() == ::fltk::LeftButton ||
-         ::fltk::event_button() == ::fltk::MiddleButton))) {
+       ((::fltk::event_key() == FL_Enter) ||
+        (::fltk::event_button() == FL_LEFT_MOUSE ||
+         ::fltk::event_button() == FL_MIDDLE_MOUSE))) {
       res->click_x = ::fltk::event_x();
       res->click_y = ::fltk::event_y();
       dw::core::EventButton event;
@@ -518,7 +518,7 @@
 void FltkEntryResource::widgetCallback (::fltk::Widget *widget,
                                         void *data)
 {
-   /* The (::fltk::event_key() == ::fltk::ReturnKey) test
+   /* The (::fltk::event_key() == FL_Enter) test
     * is necessary because WHEN_ENTER_KEY also includes
     * other events we're not interested in. For instance pressing
     * The Back or Forward, buttons, or the first click on a rendered
@@ -526,7 +526,7 @@
     */
    _MSG("when = %d\n", widget->when ());
    if ((widget->when () & ::fltk::WHEN_ENTER_KEY_ALWAYS) &&
-       (::fltk::event_key() == ::fltk::ReturnKey))
+       (::fltk::event_key() == FL_Enter))
       ((FltkEntryResource*)data)->emitActivate ();
 }
 
--- a/dw/fltkviewport.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/dw/fltkviewport.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -229,8 +229,8 @@
    case ::fltk::KEY:
       /* Tell fltk we want to receive KEY events as SHORTCUT.
        * As we don't know the exact keybindings set by the user, we ask
-       * for all of them (except TabKey to keep form navigation). */
-      if (::fltk::event_key() != TabKey)
+       * for all of them (except Tab to keep form navigation). */
+      if (::fltk::event_key() != FL_Tab)
          return 0;
       break;
 
@@ -241,7 +241,7 @@
        * and thereby unfocus any form widgets.
        * Otherwise we let fltk do the focus handling.
        */
-      if (::fltk::event_button() == ::fltk::LeftButton || focus_index() < 0) {
+      if (::fltk::event_button() == FL_LEFT_MOUSE || focus_index() < 0) {
          focus_index(-1);
          return 1;
       }
@@ -253,7 +253,7 @@
 
    case ::fltk::PUSH:
       take_focus();
-      if (::fltk::event_button() == ::fltk::MiddleButton) {
+      if (::fltk::event_button() == FL_MIDDLE_MOUSE) {
          /* pass event so that middle click can open link in new window */
          if (FltkWidgetView::handle (event) == 0) {
             dragScrolling = 1;
@@ -266,7 +266,7 @@
       break;
 
    case ::fltk::DRAG:
-      if (::fltk::event_button() == ::fltk::MiddleButton) {
+      if (::fltk::event_button() == FL_MIDDLE_MOUSE) {
          if (dragScrolling) {
             scroll(dragX - ::fltk::event_x(), dragY - ::fltk::event_y());
             dragX = ::fltk::event_x();
@@ -281,7 +281,7 @@
       break;
 
    case ::fltk::RELEASE:
-      if (::fltk::event_button() == ::fltk::MiddleButton) {
+      if (::fltk::event_button() == FL_MIDDLE_MOUSE) {
          dragScrolling = 0;
          setCursor (core::style::CURSOR_DEFAULT);
       }
--- a/src/findbar.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/src/findbar.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -35,15 +35,15 @@
 {
    _MSG("findbar MyInput::handle()\n");
    int ret = 1, k = event_key();
-   unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META);
+   unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META);
 
    if (e == KEY) {
-      if (k == LeftKey || k == RightKey) {
-         if (modifier == SHIFT) {
+      if (k == FL_Left || k == FL_Right) {
+         if (modifier == FL_SHIFT) {
             a_UIcmd_send_event_to_tabs_by_wid(e, this);
             return 1;
          }
-      } else if (k == EscapeKey && modifier == 0) {
+      } else if (k == FL_Escape && modifier == 0) {
          // Avoid clearing the text with Esc, just hide the findbar.
          return 0;
       }
@@ -92,7 +92,7 @@
     * Somehow fltk even regards the first loss of focus for the
     * window as a WHEN_ENTER_KEY_ALWAYS event.
     */
-   if (event_key() == ReturnKey)
+   if (event_key() == FL_Enter)
       search_cb(widget, vfb);
 }
 
@@ -139,13 +139,13 @@
 
     next_btn = new HighlightButton(x, border, button_width, height, "Next");
     x += button_width + gap;
-    next_btn->add_shortcut(ReturnKey);
-    next_btn->add_shortcut(KeypadEnter);
+    next_btn->add_shortcut(FL_Enter);
+    next_btn->add_shortcut(FL_KP_Enter);
     next_btn->callback(search_cb, this);
     next_btn->clear_tab_to_focus();
 
     prev_btn= new HighlightButton(x, border, button_width, height, "Previous");
-    prev_btn->add_shortcut(SHIFT+ReturnKey);
+    prev_btn->add_shortcut(FL_SHIFT+FL_Enter);
     prev_btn->callback(searchBackwards_cb, this);
     prev_btn->clear_tab_to_focus();
     x += button_width + gap;
@@ -172,15 +172,15 @@
 }
 
 /*
- * Handle events. Used to catch EscapeKey events.
+ * Handle events. Used to catch FL_Escape events.
  */
 int Findbar::handle(int event)
 {
    int ret = 0;
    int k = event_key();
-   unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META);
+   unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META);
 
-   if (event == KEY && modifier == 0 && k == EscapeKey) {
+   if (event == KEY && modifier == 0 && k == FL_Escape) {
       hide();
       ret = 1;
    }
--- a/src/keys.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/src/keys.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -38,80 +38,80 @@
  *  Local data
  */
 static const Mapping_t keyNames[] = {
-   { "Backspace",   fltk::BackSpaceKey },
-   { "Delete",      fltk::DeleteKey    },
-   { "Down",        fltk::DownKey      },
-   { "End",         fltk::EndKey       },
-   { "Esc",         fltk::EscapeKey    },
-   { "F1",          fltk::F1Key        },
-   { "F2",          fltk::F2Key        },
-   { "F3",          fltk::F3Key        },
-   { "F4",          fltk::F4Key        },
-   { "F5",          fltk::F5Key        },
-   { "F6",          fltk::F6Key        },
-   { "F7",          fltk::F7Key        },
-   { "F8",          fltk::F8Key        },
-   { "F9",          fltk::F9Key        },
-   { "F10",         fltk::F10Key       },
-   { "F11",         fltk::F11Key       },
-   { "F12",         fltk::F12Key       },
-   { "Home",        fltk::HomeKey      },
-   { "Insert",      fltk::InsertKey    },
-   { "Left",        fltk::LeftKey      },
-   { "PageDown",    fltk::PageDownKey  },
-   { "PageUp",      fltk::PageUpKey    },
-   { "Print",       fltk::PrintKey     },
-   { "Return",      fltk::ReturnKey    },
-   { "Right",       fltk::RightKey     },
-   { "Space",       fltk::SpaceKey     },
-   { "Tab",         fltk::TabKey       },
-   { "Up",          fltk::UpKey        }
+   { "Backspace",   FL_BackSpace },
+   { "Delete",      FL_Delete    },
+   { "Down",        FL_Down      },
+   { "End",         FL_End       },
+   { "Esc",         FL_Escape    },
+   { "F1",          FL_F1        },
+   { "F2",          FL_F2        },
+   { "F3",          FL_F3        },
+   { "F4",          FL_F4        },
+   { "F5",          FL_F5        },
+   { "F6",          FL_F6        },
+   { "F7",          FL_F7        },
+   { "F8",          FL_F8        },
+   { "F9",          FL_F9        },
+   { "F10",         FL_F10       },
+   { "F11",         FL_F11       },
+   { "F12",         FL_F12       },
+   { "Home",        FL_Home      },
+   { "Insert",      FL_Insert    },
+   { "Left",        FL_Left      },
+   { "PageDown",    FL_Page_Down },
+   { "PageUp",      FL_Page_Up   },
+   { "Print",       FL_Print     },
+   { "Return",      FL_Enter     },
+   { "Right",       FL_Right     },
+   { "Space",       ' '          },
+   { "Tab",         FL_Tab       },
+   { "Up",          FL_Up        }
 };
 
 static const Mapping_t modifierNames[] = {
-   { "Shift",   fltk::SHIFT   },
-   { "Ctrl",    fltk::CTRL    },
-   { "Alt",     fltk::ALT     },
-   { "Meta",    fltk::META    },
-   { "Button1", fltk::BUTTON1 },
-   { "Button2", fltk::BUTTON2 },
-   { "Button3", fltk::BUTTON3 }
+   { "Shift",   FL_SHIFT   },
+   { "Ctrl",    FL_CTRL    },
+   { "Alt",     FL_ALT     },
+   { "Meta",    FL_META    },
+   { "Button1", FL_BUTTON1 },
+   { "Button2", FL_BUTTON2 },
+   { "Button3", FL_BUTTON3 }
 };
 
 static const KeyBinding_t default_keys[] = {
-   { "nop"          , KEYS_NOP          , 0            , 0                  },
-   { "open"         , KEYS_OPEN         , fltk::CTRL   , 'o'                },
-   { "new-window"   , KEYS_NEW_WINDOW   , fltk::CTRL   , 'n'                },
-   { "new-tab"      , KEYS_NEW_TAB      , fltk::CTRL   , 't'                },
-   { "left-tab"     , KEYS_LEFT_TAB     , fltk::SHIFT  , fltk::TabKey       },
-   { "right-tab"    , KEYS_RIGHT_TAB    , fltk::CTRL   , fltk::TabKey       },
-   { "close-tab"    , KEYS_CLOSE_TAB    , fltk::CTRL   , 'q'                },
-   { "find"         , KEYS_FIND         , fltk::CTRL   , 'f'                },
-   { "websearch"    , KEYS_WEBSEARCH    , fltk::CTRL   , 's'                },
-   { "bookmarks"    , KEYS_BOOKMARKS    , fltk::CTRL   , 'b'                },
-   { "fullscreen"   , KEYS_FULLSCREEN   , fltk::CTRL   , fltk::SpaceKey     },
-   { "reload"       , KEYS_RELOAD       , fltk::CTRL   , 'r'                },
-   { "stop"         , KEYS_STOP         , 0            , 0                  },
-   { "save"         , KEYS_SAVE         , 0            , 0                  },
-   { "hide-panels"  , KEYS_HIDE_PANELS  , 0            , fltk::EscapeKey    },
-   { "file-menu"    , KEYS_FILE_MENU    , fltk::ALT    , 'f'                },
-   { "close-all"    , KEYS_CLOSE_ALL    , fltk::ALT    , 'q'                },
-   { "back"         , KEYS_BACK         , 0            , fltk::BackSpaceKey },
-   { "back"         , KEYS_BACK         , 0            , ','                },
-   { "forward"      , KEYS_FORWARD      , fltk::SHIFT  , fltk::BackSpaceKey },
-   { "forward"      , KEYS_FORWARD      , 0            , '.'                },
-   { "goto"         , KEYS_GOTO         , fltk::CTRL   , 'l'                },
-   { "home"         , KEYS_HOME         , fltk::CTRL   , 'h'                },
-   { "screen-up"    , KEYS_SCREEN_UP    , 0            , fltk::PageUpKey    },
-   { "screen-up"    , KEYS_SCREEN_UP    , 0            , 'b'                },
-   { "screen-down"  , KEYS_SCREEN_DOWN  , 0            , fltk::PageDownKey  },
-   { "screen-down"  , KEYS_SCREEN_DOWN  , 0            , fltk::SpaceKey     },
-   { "line-up"      , KEYS_LINE_UP      , 0            , fltk::UpKey        },
-   { "line-down"    , KEYS_LINE_DOWN    , 0            , fltk::DownKey      },
-   { "left"         , KEYS_LEFT         , 0            , fltk::LeftKey      },
-   { "right"        , KEYS_RIGHT        , 0            , fltk::RightKey     },
-   { "top"          , KEYS_TOP          , 0            , fltk::HomeKey      },
-   { "bottom"       , KEYS_BOTTOM       , 0            , fltk::EndKey       },
+   { "nop"          , KEYS_NOP          , 0         , 0               },
+   { "open"         , KEYS_OPEN         , FL_CTRL   , 'o'             },
+   { "new-window"   , KEYS_NEW_WINDOW   , FL_CTRL   , 'n'             },
+   { "new-tab"      , KEYS_NEW_TAB      , FL_CTRL   , 't'             },
+   { "left-tab"     , KEYS_LEFT_TAB     , FL_SHIFT  , FL_Tab          },
+   { "right-tab"    , KEYS_RIGHT_TAB    , FL_CTRL   , FL_Tab          },
+   { "close-tab"    , KEYS_CLOSE_TAB    , FL_CTRL   , 'q'             },
+   { "find"         , KEYS_FIND         , FL_CTRL   , 'f'             },
+   { "websearch"    , KEYS_WEBSEARCH    , FL_CTRL   , 's'             },
+   { "bookmarks"    , KEYS_BOOKMARKS    , FL_CTRL   , 'b'             },
+   { "fullscreen"   , KEYS_FULLSCREEN   , FL_CTRL   , ' '             },
+   { "reload"       , KEYS_RELOAD       , FL_CTRL   , 'r'             },
+   { "stop"         , KEYS_STOP         , 0         , 0               },
+   { "save"         , KEYS_SAVE         , 0         , 0               },
+   { "hide-panels"  , KEYS_HIDE_PANELS  , 0         , FL_Escape       },
+   { "file-menu"    , KEYS_FILE_MENU    , FL_ALT    , 'f'             },
+   { "close-all"    , KEYS_CLOSE_ALL    , FL_ALT    , 'q'             },
+   { "back"         , KEYS_BACK         , 0         , FL_BackSpace    },
+   { "back"         , KEYS_BACK         , 0         , ','             },
+   { "forward"      , KEYS_FORWARD      , FL_SHIFT  , FL_BackSpace    },
+   { "forward"      , KEYS_FORWARD      , 0         , '.'             },
+   { "goto"         , KEYS_GOTO         , FL_CTRL   , 'l'             },
+   { "home"         , KEYS_HOME         , FL_CTRL   , 'h'             },
+   { "screen-up"    , KEYS_SCREEN_UP    , 0         , FL_Page_Up      },
+   { "screen-up"    , KEYS_SCREEN_UP    , 0         , 'b'             },
+   { "screen-down"  , KEYS_SCREEN_DOWN  , 0         , FL_Page_Down    },
+   { "screen-down"  , KEYS_SCREEN_DOWN  , 0         , ' '             },
+   { "line-up"      , KEYS_LINE_UP      , 0         , FL_Up           },
+   { "line-down"    , KEYS_LINE_DOWN    , 0         , FL_Down         },
+   { "left"         , KEYS_LEFT         , 0         , FL_Left         },
+   { "right"        , KEYS_RIGHT        , 0         , FL_Right        },
+   { "top"          , KEYS_TOP          , 0         , FL_Home         },
+   { "bottom"       , KEYS_BOTTOM       , 0         , FL_End          },
 };
 
 static Dlist *bindings;
@@ -174,9 +174,9 @@
    KeyBinding_t keyNode;
    // We're only interested in some flags
    keyNode.modifier = fltk::event_state() &
-     (fltk::SHIFT | fltk::CTRL | fltk::ALT | fltk::META);
+     (FL_SHIFT | FL_CTRL | FL_ALT | FL_META);
 
-   if (keyNode.modifier == fltk::SHIFT &&
+   if (keyNode.modifier == FL_SHIFT &&
        ispunct(fltk::event_text()[0])) {
       // Get key code for a shifted character
       keyNode.key = fltk::event_text()[0];
--- a/src/menu.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/src/menu.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -139,7 +139,7 @@
 static void Menu_open_url_nt_cb(Widget* )
 {
    int focus = prefs.focus_new_tab ? 1 : 0;
-   if (event_state(SHIFT)) focus = !focus;
+   if (event_state(FL_SHIFT)) focus = !focus;
    a_UIcmd_open_url_nt(popup_bw, popup_url, focus);
 }
 
@@ -293,7 +293,7 @@
       // Middle button, open in a new window/tab
       if (prefs.middle_click_opens_new_tab) {
          int focus = prefs.focus_new_tab ? 1 : 0;
-         if (event_state(SHIFT)) focus = !focus;
+         if (event_state(FL_SHIFT)) focus = !focus;
          a_UIcmd_open_url_nt(popup_bw, url, focus);
       } else {
          a_UIcmd_open_url_nw(popup_bw, url);
--- a/src/ui.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/src/ui.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -103,8 +103,8 @@
 };
 
 /*
- * Disable: UpKey, DownKey, PageUpKey, PageDownKey and
- * CTRL+{o,r,HomeKey,EndKey}
+ * Disable keys: Up, Down, Page_Up, Page_Down and
+ * CTRL+{o,r,Home,End}
  */
 int CustInput::handle(int e)
 {
@@ -113,23 +113,23 @@
    _MSG("CustInput::handle event=%d\n", e);
 
    // We're only interested in some flags
-   unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
+   unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
 
    // Don't focus with arrow keys
    if (e == FOCUS &&
-       (k == UpKey || k == DownKey || k == LeftKey || k == RightKey)) {
+       (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
       return 0;
    } else if (e == KEY) {
-      if (modifier == CTRL) {
+      if (modifier == FL_CTRL) {
          if (k == 'l') {
             // Make text selected when already focused.
             position(size(), 0);
             return 1;
-         } else if (k == 'o' || k == 'r' || k == HomeKey || k == EndKey)
+         } else if (k == 'o' || k == 'r' || k == FL_Home || k == FL_End)
             return 0;
-      } else if (modifier == SHIFT) {
-         if (k == LeftKey || k == RightKey) {
-            _MSG(" CustInput::handle > SHIFT+RightKey\n");
+      } else if (modifier == FL_SHIFT) {
+         if (k == FL_Left || k == FL_Right) {
+            _MSG(" CustInput::handle > FL_SHIFT+FL_Right\n");
             a_UIcmd_send_event_to_tabs_by_wid(e, this);
             return 1;
          }
@@ -288,7 +288,7 @@
     * other events we're not interested in. For instance pressing
     * The Back or Forward, buttons, or the first click on a rendered
     * page. BUG: this must be investigated and reported to FLTK2 team */
-   if (event_key() == ReturnKey) {
+   if (event_key() == FL_Enter) {
       a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value());
    }
    if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) {
@@ -853,7 +853,7 @@
       }
    } else if (event == PUSH) {
       if (prefs.middle_click_drags_page == 0 &&
-          event_button() == MiddleButton &&
+          event_button() == FL_MIDDLE_MOUSE &&
           !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) {
          if (Main->Rectangle::contains (event_x (), event_y ())) {
             /* Offer the event to Main's children (form widgets) */
--- a/src/uicmd.cc	Thu Jan 06 00:18:56 2011 +0000
+++ b/src/uicmd.cc	Thu Jan 06 02:15:06 2011 +0000
@@ -249,13 +249,13 @@
       if (e == KEY) {
          int k = event_key();
          // We're only interested in some flags
-         unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
-         if (k == UpKey || k == DownKey || k == TabKey) {
+         unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
+         if (k == FL_Up || k == FL_Down || k == FL_Tab) {
             return 0;
-         } else if (k == LeftKey || k == RightKey) {
-            if (modifier == SHIFT) {
+         } else if (k == FL_Left || k == FL_Right) {
+            if (modifier == FL_SHIFT) {
                int i = value();
-               if (k == LeftKey) {i = i ? i-1 : children()-1;}
+               if (k == FL_Left) {i = i ? i-1 : children()-1;}
                else {i++; if (i >= children()) i = 0;}
                selected_child(child(i));
                return 1;
@@ -383,7 +383,7 @@
 }
 
 /*
- * FLTK regards SHIFT + {LeftKey, Right} as navigation keys.
+ * FLTK regards SHIFT + {Left, Right} as navigation keys.
  * Special handling is required to override it. Here we route
  * these events directly to the recipient.
  * TODO: focus is not remembered correctly.