Skip to content

Commit 2101563

Browse files
committed
Fixed #9042 (Dragging and selecting text is not possible in browser)
1 parent 23f44ae commit 2101563

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

MTA10/core/CWebView.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ CWebView::CWebView ( unsigned int uiWidth, unsigned int uiHeight, bool bIsLocal,
2222
m_pEventsInterface = nullptr;
2323
m_bBeingDestroyed = false;
2424
m_fVolume = 1.0f;
25+
memset ( m_mouseButtonStates, 0, sizeof(m_mouseButtonStates) );
2526

2627
// Initialise properties
2728
m_Properties["mobile"] = "0";
@@ -222,7 +223,17 @@ void CWebView::InjectMouseMove ( int iPosX, int iPosY )
222223
CefMouseEvent mouseEvent;
223224
mouseEvent.x = iPosX;
224225
mouseEvent.y = iPosY;
226+
227+
// Set modifiers from mouse states (yeah, using enum values as indices isn't best practise, but it's the easiest solution here)
228+
if ( m_mouseButtonStates[BROWSER_MOUSEBUTTON_LEFT] )
229+
mouseEvent.modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON;
230+
if ( m_mouseButtonStates[BROWSER_MOUSEBUTTON_MIDDLE] )
231+
mouseEvent.modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON;
232+
if ( m_mouseButtonStates[BROWSER_MOUSEBUTTON_RIGHT] )
233+
mouseEvent.modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON;
234+
225235
m_pWebView->GetHost ()->SendMouseMoveEvent ( mouseEvent, false );
236+
226237
m_vecMousePosition.x = iPosX;
227238
m_vecMousePosition.y = iPosY;
228239
}
@@ -236,6 +247,9 @@ void CWebView::InjectMouseDown ( eWebBrowserMouseButton mouseButton )
236247
mouseEvent.x = m_vecMousePosition.x;
237248
mouseEvent.y = m_vecMousePosition.y;
238249

250+
// Save mouse button states
251+
m_mouseButtonStates[static_cast<int>(mouseButton)] = true;
252+
239253
m_pWebView->GetHost ()->SendMouseClickEvent ( mouseEvent, static_cast < CefBrowserHost::MouseButtonType > ( mouseButton ), false, 1 );
240254
}
241255

@@ -248,6 +262,9 @@ void CWebView::InjectMouseUp ( eWebBrowserMouseButton mouseButton )
248262
mouseEvent.x = m_vecMousePosition.x;
249263
mouseEvent.y = m_vecMousePosition.y;
250264

265+
// Save mouse button states
266+
m_mouseButtonStates[static_cast<int>(mouseButton)] = false;
267+
251268
m_pWebView->GetHost ()->SendMouseClickEvent ( mouseEvent, static_cast < CefBrowserHost::MouseButtonType > ( mouseButton ), true, 1 );
252269
}
253270

MTA10/core/CWebView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
130130
bool m_bIsLocal;
131131
bool m_bIsTransparent;
132132
POINT m_vecMousePosition;
133+
bool m_mouseButtonStates[3];
133134
SString m_CurrentTitle;
134135
float m_fVolume;
135136
std::mutex m_PaintMutex;

0 commit comments

Comments
 (0)