Browse Source

Adding focus event

JoshEngebretson 10 years ago
parent
commit
3974b7c04b

+ 2 - 0
Source/AtomicWebView/UIWebView.cpp

@@ -79,6 +79,8 @@ public:
         {
             browserCreated_ = true;
             webView_->webClient_->CreateBrowser(webView_->initialURL_, rect.w, rect.h);
+            // start focused
+            webView_->webClient_->SendFocusEvent(true);
         }
 
         webView_->webClient_->SetSize(rect.w, rect.h);

+ 9 - 0
Source/AtomicWebView/WebClient.cpp

@@ -298,6 +298,15 @@ void WebClient::SendTextInputEvent(const StringHash eventType, VariantMap& event
     host->SendKeyEvent(keyEvent);
 }
 
+void WebClient::SendFocusEvent(bool focus)
+{
+    if (!d_->browser_.get())
+        return;
+
+    CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
+    host->SendFocusEvent(focus);
+}
+
 void WebClient::ShortcutCut()
 {
     if (!d_->browser_.get())

+ 2 - 0
Source/AtomicWebView/WebClient.h

@@ -38,6 +38,8 @@ public:
     void SendMouseMoveEvent(int x, int y, unsigned modifier, bool mouseLeave = false) const;
     void SendMouseWheelEvent(int x, int y, unsigned modifier, int deltaX, int deltaY) const;
 
+    void SendFocusEvent(bool focus = true);
+
     void SendTextInputEvent(const StringHash eventType, VariantMap& eventData);
     void SendKeyEvent(const StringHash eventType, VariantMap& eventData);
 

+ 1 - 2
Source/AtomicWebView/WebTexture2D.cpp

@@ -30,6 +30,7 @@ public:
     WebTexture2DPrivate(WebTexture2D* webTexture2D)
     {
         webTexture2D_ = webTexture2D;
+        ClearPopupRects();
     }
 
     void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) OVERRIDE
@@ -238,10 +239,8 @@ public:
             for (; i != dirtyRects.end(); ++i)
             {
                 const CefRect& rect = *i;
-
                 unsigned char* src = (unsigned char*) buffer;
                 src += rect.y * (width * 4) + (rect.x * 4);
-
                 D3D9Blit(IntRect(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height), src, width * 4, false);
             }