Skip to content

Instantly share code, notes, and snippets.

@PBfordev
Created April 25, 2020 20:15
Show Gist options
  • Save PBfordev/b1c3822e62bc915b6d44f45e6c352cb1 to your computer and use it in GitHub Desktop.
Save PBfordev/b1c3822e62bc915b6d44f45e6c352cb1 to your computer and use it in GitHub Desktop.
Needed for js-to-wx.cpp gist
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="UTF-8">
</head>
<body>
<h1>Title H1</h1>
<p>Right click or double click inside the document to trigger a response inside wxWidgets C++ code.</p>
<script>
const wxWebViewProtocol = 'wxwebview://';
function onDocumentContextMenu(evt)
{
evt.preventDefault();
var command = wxWebViewProtocol + 'document_contextMenu/params?'+
'clientX=' + evt.clientX +
'&clientY=' + evt.clientY;
window.location.assign(command);
console.log(command);
}
function onDocumentDblClick(evt)
{
var command = wxWebViewProtocol + 'document_dblClick/params?'+
'clientX=' + evt.clientX +
'&clientY=' + evt.clientY;
window.location.assign(command);
console.log(command);
}
document.addEventListener('contextmenu', onDocumentContextMenu);
document.addEventListener('dblclick', onDocumentDblClick);
</script>
</body>
</html>
@PBfordev
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment