Hi all,
Thanks to Greg I’ve advanced a lot with the exploration of the WebControlWrapper. I’m trying to write some kind of game engine with it and the graphics are going very well. But now interaction is needed, and I’m stuck trying all day I’m afraid…
I’m trying to receive a mouse down event from my WebControlWrapper.
Here is the relevant code of my latest trial in SetupJavascriptFramework:
...
s.Append "XojoCustom.alwaysbusy.abwebcanvas.initialize = function initialize(cControlID, cWidth, cHeight) {"
s.Append " width=cWidth;"
s.Append " height=cHeight;"
s.Append " controlID=cControlID;"
s.Append " var tmpView;"
s.Append " tmpView = document.getElementById(controlID);"
s.Append " tmpView.addEventListener('mousedown', function(event) {"
s.Append " var x = event.pageX;"
s.Append " var y = event.pageY;"
s.Append " console.log('x:' + x + ',y:' + y);"
s.Append " Xojo.triggerServerEvent(controlID, 'mousedown', [x,y]);"
s.Append " }, false);"
s.Append "};"
...
in ExecuteEvent: (but this is never triggered, at least the breakpoint is never reached)
select case Name
case "mousedown"
Return MouseDown(Parameters(0), Parameters(1))
end select
The MouseDown event definition:
Event MouseDown(x as integer, y as integer) As Boolean
The event on the control on the webpage:
Function MouseDown(x as integer, y as integer) As Boolean
MsgBox str(x)
End Function
I see the correct ‘console.log()’ in the console when I click on the webcontrol and Xojo must receive something, as the debugger goes in pauze but does not enter the ExecuteEvent() handler. When I press play it continues and I can click again with the same result.
Anyone who can shine some light on triggerServerEvent (and triggerBrowserEvent) as the 8 lines in the WebSDK documentation are not a big help, nor a google search on ‘Xojo triggerServerEvent’ or the examples.
(Windows 7, Firefox in case it matters)
Thanks in advance, I really do want to understand the WebSDK because this shows great potential!
Alain