Feature/touch web gui support (#798)

* Added touch support for web GUI

* Code cleanup after master merge, no functionality changes

* Fixed alignment of function arguments
This commit is contained in:
Gene Payne
2019-02-21 07:35:47 -07:00
committed by GitHub
parent 21fd957f28
commit c44290fe1f
10 changed files with 124 additions and 10 deletions
@@ -84,6 +84,12 @@ public:
void draw();
void close(bool force = false);
void sendTouchPressEvent(const CefMouseEvent & event,
CefBrowserHost::MouseButtonType button, const int clickCount);
void sendResleasePressEvent(const CefMouseEvent & event,
CefBrowserHost::MouseButtonType button, const int clickCount);
bool sendKeyEvent(const CefKeyEvent& event);
bool sendMouseClickEvent(const CefMouseEvent& event,
CefBrowserHost::MouseButtonType button, bool mouseUp,
@@ -60,6 +60,9 @@ public:
void setBrowser(const CefRefPtr<CefBrowser>& browser);
void setBrowserInstance(BrowserInstance* browserInstance);
void detachBrowser();
void touchPressCallback(const double x, const double y);
void touchReleaseCallback(const double x, const double y);
bool hasContentCallback(const double, const double);
private:
bool mouseButtonCallback(MouseButton button, MouseAction action, KeyModifier mods);
@@ -131,6 +131,18 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event,
return hasContent(event.x, event.y);
}
void BrowserInstance::sendTouchPressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
const int clickCount)
{
_browser->GetHost()->SendMouseClickEvent(event, button, false, clickCount);
}
void BrowserInstance::sendResleasePressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
const int clickCount)
{
_browser->GetHost()->SendMouseClickEvent(event, button, true, clickCount);
}
bool BrowserInstance::sendMouseMoveEvent(const CefMouseEvent& event) {
constexpr const bool DidNotLeaveWindow = false;
+24
View File
@@ -143,6 +143,30 @@ void EventHandler::initialize() {
);
}
void EventHandler::touchPressCallback(const double x, const double y) {
if (_browserInstance) {
_mousePosition.x = static_cast<float>(x);
_mousePosition.y = static_cast<float>(y);
int clickCount = BrowserInstance::SingleClick;
_browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, false, clickCount);
}
}
void EventHandler::touchReleaseCallback(const double x, const double y) {
if (_browserInstance) {
_mousePosition.x = static_cast<float>(x);
_mousePosition.y = static_cast<float>(y);
int clickCount = BrowserInstance::SingleClick;
_browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, true, clickCount);
}
}
bool EventHandler::hasContentCallback(const double x, const double y) {
return _browserInstance->hasContent(static_cast<int>(x), static_cast<int>(y));
}
bool EventHandler::mouseButtonCallback(MouseButton button,
MouseAction action,
KeyModifier mods)
+4
View File
@@ -140,6 +140,10 @@ void WebBrowserModule::attachEventHandler(BrowserInstance* browserInstance) {
}
}
EventHandler WebBrowserModule::eventHandler() {
return _eventHandler;
}
void WebBrowserModule::detachEventHandler() {
if (_enabled) {
_eventHandler.setBrowserInstance(nullptr);
+1
View File
@@ -42,6 +42,7 @@ public:
void addBrowser(BrowserInstance*);
void removeBrowser(BrowserInstance*);
EventHandler eventHandler();
void attachEventHandler(BrowserInstance* browserInstance);
void detachEventHandler();
bool isEnabled() const;