Skip to content

Commit 2b8d15d

Browse files
committed
Added support for middle-mouse button click in miniwindow hotspots
1 parent a12a478 commit 2b8d15d

File tree

3 files changed

+75
-13
lines changed

3 files changed

+75
-13
lines changed

mushview.cpp

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ BEGIN_MESSAGE_MAP(CMUSHView, CView)
262262
ACCELERATOR_FIRST_COMMAND + ACCELERATOR_COUNT - 1,
263263
OnAcceleratorCommand)
264264

265+
// middle mouse button
266+
ON_WM_MBUTTONDOWN()
267+
ON_WM_MBUTTONUP()
268+
269+
265270
END_MESSAGE_MAP()
266271

267272
/////////////////////////////////////////////////////////////////////////////
@@ -2098,7 +2103,7 @@ int line,
20982103
dc.DPtoLP(&point);
20992104

21002105
// if click in mini-window, don't continue
2101-
if (Mouse_Down_MiniWindow (pDoc, point, 0x10)) // LH mouse, single click
2106+
if (Mouse_Down_MiniWindow (pDoc, point, MW_MOUSE_LH)) // LH mouse, single click
21022107
return;
21032108

21042109
// check for the rectangle, now we are past the miniwindow stuff
@@ -2359,12 +2364,32 @@ ASSERT_VALID(pDoc);
23592364
dc.DPtoLP(&mwpoint);
23602365

23612366
// if click in mini-window, don't continue
2362-
if (Mouse_Down_MiniWindow (pDoc, mwpoint, 0x20)) // RH mouse, single click
2367+
if (Mouse_Down_MiniWindow (pDoc, mwpoint, MW_MOUSE_RH)) // RH mouse, single click
23632368
return;
23642369

23652370
CView::OnRButtonDown(nFlags, point);
23662371
}
23672372

2373+
void CMUSHView::OnMButtonDown(UINT nFlags, CPoint point)
2374+
{
2375+
CMUSHclientDoc* pDoc = GetDocument();
2376+
ASSERT_VALID(pDoc);
2377+
2378+
2379+
// CView changes the viewport origin and mapping mode.
2380+
// It's necessary to convert the point from device coordinates
2381+
// to logical coordinates, such as are stored in the document.
2382+
CPoint mwpoint = point;
2383+
CClientDC dc(this);
2384+
OnPrepareDC(&dc);
2385+
dc.DPtoLP(&mwpoint);
2386+
2387+
// if click in mini-window, don't continue
2388+
if (Mouse_Down_MiniWindow (pDoc, mwpoint, MW_MOUSE_MIDDLE)) // middle mouse, single click
2389+
return;
2390+
2391+
CView::OnMButtonDown(nFlags, point);
2392+
}
23682393

23692394
void CMUSHView::OnLButtonUp(UINT nFlags, CPoint point)
23702395
{
@@ -2388,7 +2413,7 @@ int line,
23882413

23892414

23902415
// if miniwindow handles it, don't continue
2391-
if (Mouse_Up_MiniWindow (pDoc, point, 0x10))
2416+
if (Mouse_Up_MiniWindow (pDoc, point, MW_MOUSE_LH))
23922417
return;
23932418

23942419
if (GetCapture() != this)
@@ -2454,13 +2479,36 @@ ASSERT_VALID(pDoc);
24542479

24552480

24562481
// if miniwindow handles it, don't continue
2457-
if (Mouse_Up_MiniWindow (pDoc, mwpoint, 0x20))
2482+
if (Mouse_Up_MiniWindow (pDoc, mwpoint, MW_MOUSE_RH))
24582483
return;
24592484

24602485

24612486
CView::OnRButtonUp(nFlags, point);
24622487
}
24632488

2489+
void CMUSHView::OnMButtonUp(UINT nFlags, CPoint point)
2490+
{
2491+
CMUSHclientDoc* pDoc = GetDocument();
2492+
ASSERT_VALID(pDoc);
2493+
2494+
2495+
CClientDC dc(this);
2496+
2497+
// CView changes the viewport origin and mapping mode.
2498+
// It's necessary to convert the point from device coordinates
2499+
// to logical coordinates, such as are stored in the document.
2500+
CPoint mwpoint = point;
2501+
OnPrepareDC(&dc); // set up mapping mode and viewport origin
2502+
dc.DPtoLP(&mwpoint);
2503+
2504+
2505+
// if miniwindow handles it, don't continue
2506+
if (Mouse_Up_MiniWindow (pDoc, mwpoint, MW_MOUSE_MIDDLE))
2507+
return;
2508+
2509+
2510+
CView::OnMButtonUp(nFlags, point);
2511+
}
24642512

24652513

24662514
void CMUSHView::OnMouseMove(UINT nFlags, CPoint point)
@@ -4667,7 +4715,7 @@ int line,
46674715
dc.DPtoLP(&point);
46684716

46694717
// if click in mini-window, don't continue
4670-
if (Mouse_Down_MiniWindow (pDoc, point, 0x50)) // LH mouse - double click
4718+
if (Mouse_Down_MiniWindow (pDoc, point, MW_MOUSE_LH | MW_MOUSE_DBL)) // LH mouse - double click
46714719
return;
46724720

46734721

@@ -4830,7 +4878,7 @@ ASSERT_VALID(pDoc);
48304878
dc.DPtoLP(&mwpoint);
48314879

48324880
// if click in mini-window, don't continue
4833-
if (Mouse_Down_MiniWindow (pDoc, mwpoint, 0x60)) // RH mouse - double click
4881+
if (Mouse_Down_MiniWindow (pDoc, mwpoint, MW_MOUSE_RH | MW_MOUSE_DBL)) // RH mouse - double click
48344882
return;
48354883

48364884
CView::OnRButtonDblClk(nFlags, point);
@@ -5081,7 +5129,7 @@ unsigned int iScrollLines;
50815129

50825130
// if over miniwindow, don't keep going
50835131

5084-
if (Mouse_Wheel_MiniWindow (pDoc, point, zDelta < 0 ? 0x100 : 0))
5132+
if (Mouse_Wheel_MiniWindow (pDoc, point, zDelta < 0 ? MW_MOUSE_SCROLL_BACK : 0))
50855133
return 1;
50865134

50875135
/*
@@ -6424,13 +6472,13 @@ ASSERT_VALID(pDoc);
64246472
if (!dont_modify_flags)
64256473
{
64266474
if (GetKeyState (VK_SHIFT) < 0) // shift+click
6427-
Flags |= 1;
6475+
Flags |= MW_MOUSE_SHIFT;
64286476

64296477
if (GetKeyState (VK_CONTROL) < 0) // ctrl+click
6430-
Flags |= 2;
6478+
Flags |= MW_MOUSE_CTRL;
64316479

64326480
if (GetKeyState (VK_MENU) < 0) // alt+click
6433-
Flags |= 4;
6481+
Flags |= MW_MOUSE_ALT;
64346482
} // can modify flags
64356483

64366484

@@ -6784,7 +6832,7 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
67846832
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseOver,
67856833
mw->m_sCallbackPlugin,
67866834
pHotspot->m_sMouseOver,
6787-
sHotspotId, 0x80);
6835+
sHotspotId, MW_MOUSE_NOT_FIRST);
67886836
mw->m_bExecutingScript = false;
67896837
}
67906838

@@ -6882,7 +6930,7 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
68826930
// now, are we now over a hotspot?
68836931
if (pHotspot)
68846932
{
6885-
mw->m_FlagsOnMouseDown = flags & 0x70; // remember mouse flags
6933+
mw->m_FlagsOnMouseDown = flags & (MW_MOUSE_LH | MW_MOUSE_RH | MW_MOUSE_DBL | MW_MOUSE_MIDDLE); // remember mouse flags
68866934
mw->m_bExecutingScript = true;
68876935
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseDown,
68886936
mw->m_sCallbackPlugin,
@@ -7094,7 +7142,7 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
70947142
mw->m_sCallbackPlugin,
70957143
pHotspot->m_sMouseUp,
70967144
sHotspotId,
7097-
mw->m_FlagsOnMouseDown); // LH / RH mouse?
7145+
mw->m_FlagsOnMouseDown); // LH / RH / middle mouse?
70987146
mw->m_bExecutingScript = false;
70997147
}
71007148

mushview.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
#define MXP_FIRST_MENU 10000
88
#define MXP_MENU_COUNT 100 // number of MXP menu items we support
99

10+
#define MW_MOUSE_SHIFT 0x01
11+
#define MW_MOUSE_CTRL 0x02
12+
#define MW_MOUSE_ALT 0x04
13+
#define MW_MOUSE_LH 0x10
14+
#define MW_MOUSE_RH 0x20
15+
#define MW_MOUSE_DBL 0x40
16+
#define MW_MOUSE_NOT_FIRST 0x80
17+
#define MW_MOUSE_SCROLL_BACK 0x100
18+
#define MW_MOUSE_MIDDLE 0x200
19+
1020
class CMUSHView : public CView
1121
{
1222

@@ -260,6 +270,9 @@ void BookmarkLine (const long iLine);
260270
afx_msg void OnMXPMenu(UINT nID);
261271
afx_msg void OnAcceleratorCommand(UINT nID);
262272
afx_msg void OnUpdateNeedSelectionForCopy(CCmdUI* pCmdUI);
273+
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
274+
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
275+
263276
DECLARE_MESSAGE_MAP()
264277
};
265278

scripting/lua_methods.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7703,6 +7703,7 @@ static flags_pair miniwindow_flags [] =
77037703
{ "hotspot_got_rh_mouse", 0x20 },
77047704
{ "hotspot_got_dbl_click", 0x40 },
77057705
{ "hotspot_got_not_first", 0x80 },
7706+
{ "hotspot_got_middle_mouse", 0x200 },
77067707

77077708
// WindowMergeImageAlpha Mode (argument 8)
77087709

0 commit comments

Comments
 (0)