diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2024-09-26 17:59:52 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <fltk@aljus.de> | 2024-10-06 18:53:03 +0200 |
| commit | 4f4a9be15b0c52837dd4d4a04ff021cc3e5d691e (patch) | |
| tree | a7238b08a93b2af73c4df86a66b7abfa47689e76 /src/Fl_win32.cxx | |
| parent | 3fbd4f944f0a6e16630974e56e1e896eb7bbf6f7 (diff) | |
Support mouse buttons 4 + 5 (aka "side buttons") (#1076, #1068)
This work is based on PR 1068 (patch by @CendioHalim) and
extended to store button status (4,5) in Fl::event_state() like
it's done for other mouse buttons (1-3).
Changes:
- new symbol: FL_BUTTON4 = side button 1 = "back"
- new symbol: FL_BUTTON5 = side button 2 = "forward"
- modified : FL_BUTTONS now includes bits for two side buttons
Note: the status of these new buttons is not maintained by X11,
therefore we need to maintain them in internal variables for
this platform.
Diffstat (limited to 'src/Fl_win32.cxx')
| -rw-r--r-- | src/Fl_win32.cxx | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 36e77a99b..dec95241e 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1044,9 +1044,12 @@ static int mouse_event(Fl_Window *window, int what, int button, if (wParam & MK_SHIFT) state |= FL_SHIFT; if (wParam & MK_CONTROL) state |= FL_CTRL; #endif - if (wParam & MK_LBUTTON) state |= FL_BUTTON1; - if (wParam & MK_MBUTTON) state |= FL_BUTTON2; - if (wParam & MK_RBUTTON) state |= FL_BUTTON3; + if (wParam & MK_LBUTTON) state |= FL_BUTTON1; // left + if (wParam & MK_MBUTTON) state |= FL_BUTTON2; // right + if (wParam & MK_RBUTTON) state |= FL_BUTTON3; // middle + if (wParam & MK_XBUTTON1) state |= FL_BUTTON4; // side button 1 (back) + if (wParam & MK_XBUTTON2) state |= FL_BUTTON5; // side button 2 (forward) + Fl::e_state = state; switch (what) { @@ -1348,6 +1351,21 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar case WM_RBUTTONUP: mouse_event(window, 2, 3, wParam, lParam); return 0; + case WM_XBUTTONDOWN: { + int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5; + mouse_event(window, 0, xbutton, wParam, lParam); + return 0; + } + case WM_XBUTTONDBLCLK: { + int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5; + mouse_event(window, 1, xbutton, wParam, lParam); + return 0; + } + case WM_XBUTTONUP: { + int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5; + mouse_event(window, 2, xbutton, wParam, lParam); + return 0; + } case WM_MOUSEMOVE: #ifdef USE_TRACK_MOUSE |
