Browse Source

Support mouse drag in webview

Josh Engebretson 10 years ago
parent
commit
5a0430de11
2 changed files with 17 additions and 15 deletions
  1. 8 12
      Source/AtomicWebView/UIWebView.cpp
  2. 9 3
      Source/AtomicWebView/WebClient.cpp

+ 8 - 12
Source/AtomicWebView/UIWebView.cpp

@@ -81,9 +81,6 @@ public:
 
         webView_->webClient_->SetSize(rect.w, rect.h);
 
-        float umax = 1.0f;
-        float vmax = 1.0f;
-
         float color;
         float fopacity = GetOpacity() * ui->GetRenderer()->GetOpacity();
         unsigned char opacity = (unsigned char) (fopacity* 255.0f);
@@ -96,15 +93,6 @@ public:
         data[27] = color;
         data[33] = color;
 
-        // UV
-        data[4] = 0; data[5] = 0;
-        data[10] = umax; data[11] = 0;
-        data[16] = umax; data[17] = vmax;
-        data[22] = 0; data[23] = 0;
-        data[28] = umax; data[29] = vmax;
-        data[34] = 0; data[35] = vmax;
-
-
         data[0] = rect.x;
         data[1] = rect.y;
 
@@ -176,6 +164,14 @@ bool UIWebView::OnEvent(const TBWidgetEvent &ev)
         webClient_->SendMouseWheelEvent(ev.target_x, ev.target_y, 0, ev.delta_x, ev.delta_y);
         return true;
     }
+    else if (ev.type == EVENT_TYPE_KEY_DOWN)
+    {
+        return true;
+    }
+    else if (ev.type == EVENT_TYPE_KEY_UP)
+    {
+        return true;
+    }
 
 
     return UIWidget::OnEvent(ev);

+ 9 - 3
Source/AtomicWebView/WebClient.cpp

@@ -13,6 +13,7 @@
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/IO/Log.h>
+#include <Atomic/Input/Input.h>
 
 #include <Atomic/Graphics/Graphics.h>
 
@@ -195,9 +196,14 @@ void WebClient::SendMouseMoveEvent(int x, int y, unsigned modifier, bool mouseLe
     mevent.y = y;
     mevent.modifiers = 0;
 
-    //MBT_LEFT   = 0,
-    //MBT_MIDDLE,
-    //MBT_RIGHT,
+    Input* input = GetSubsystem<Input>();
+
+    if (input->GetMouseButtonDown(MOUSEB_LEFT))
+        mevent.modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON;
+    if (input->GetMouseButtonDown(MOUSEB_MIDDLE))
+        mevent.modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON;
+    if (input->GetMouseButtonDown(MOUSEB_RIGHT))
+        mevent.modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON;
 
     host->SendMouseMoveEvent(mevent, mouseLeave);