Mercurial > hg > orthanc-stone
diff Framework/Viewport/WebAssemblyViewport.cpp @ 1351:1b8e37770d78 broker
ID vs CSS selector distinction in API and field names.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 15 Apr 2020 12:57:36 +0200 |
parents | df8bf351c23f |
children | d8bb885e9b0a |
line wrap: on
line diff
--- a/Framework/Viewport/WebAssemblyViewport.cpp Tue Apr 14 14:57:06 2020 +0200 +++ b/Framework/Viewport/WebAssemblyViewport.cpp Wed Apr 15 12:57:36 2020 +0200 @@ -139,7 +139,7 @@ { WebAssemblyViewport* that = reinterpret_cast<WebAssemblyViewport*>(userData); - LOG(TRACE) << "mouse down: " << that->GetFullCanvasId(); + LOG(TRACE) << "mouse down: " << that->GetCanvasCssSelector(); if (that->compositor_.get() != NULL && that->interactor_.get() != NULL) @@ -213,8 +213,8 @@ WebAssemblyViewport::WebAssemblyViewport( const std::string& canvasId, bool enableEmscriptenMouseEvents) : - shortCanvasId_(canvasId), - fullCanvasId_(canvasId), + canvasId_(canvasId), + canvasCssSelector_("#" + canvasId), interactor_(new DefaultViewportInteractor), enableEmscriptenMouseEvents_(enableEmscriptenMouseEvents) { @@ -226,10 +226,10 @@ controller_.reset(new ViewportController(viewport)); LOG(INFO) << "Initializing Stone viewport on HTML canvas: " - << shortCanvasId_; + << canvasId_; - if (shortCanvasId_.empty() || - shortCanvasId_[0] == '#') + if (canvasId_.empty() || + canvasId_[0] == '#') { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, "The canvas identifier must not start with '#'"); @@ -243,7 +243,7 @@ event.preventDefault(); } }, - shortCanvasId_.c_str() // $0 + canvasId_.c_str() // $0 ); // It is not possible to monitor the resizing of individual @@ -256,17 +256,22 @@ if (enableEmscriptenMouseEvents_) { - emscripten_set_mousedown_callback(fullCanvasId_.c_str(), + // if any of this function causes an error in the console, please + // make sure you are using the new (as of 1.39.x) version of + // emscripten element lookup rules( pass + // "-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1" to the linker. + + emscripten_set_mousedown_callback(canvasCssSelector_.c_str(), reinterpret_cast<void*>(this), false, OnMouseDown); - emscripten_set_mousemove_callback(fullCanvasId_.c_str(), + emscripten_set_mousemove_callback(canvasCssSelector_.c_str(), reinterpret_cast<void*>(this), false, OnMouseMove); - emscripten_set_mouseup_callback(fullCanvasId_.c_str(), + emscripten_set_mouseup_callback(canvasCssSelector_.c_str(), reinterpret_cast<void*>(this), false, OnMouseUp); @@ -283,17 +288,17 @@ if (enableEmscriptenMouseEvents_) { - emscripten_set_mousedown_callback(fullCanvasId_.c_str(), + emscripten_set_mousedown_callback(canvasCssSelector_.c_str(), reinterpret_cast<void*>(this), false, OnMouseDown); - emscripten_set_mousemove_callback(fullCanvasId_.c_str(), + emscripten_set_mousemove_callback(canvasCssSelector_.c_str(), reinterpret_cast<void*>(this), false, OnMouseMove); - emscripten_set_mouseup_callback(fullCanvasId_.c_str(), + emscripten_set_mouseup_callback(canvasCssSelector_.c_str(), reinterpret_cast<void*>(this), false, OnMouseUp);