WebTextField has a KeyPressed event which maps to onkeypress. In some situations however onkeypress does not catch certain keys (in this case return/13).
I tried to catch the key press by adding the following code to the control’s shown event.
Dim js As String
js = js + " var myinput= document.getElementById('"+Me.ControlID+"').getElementsByTagName('input'); "
js = js + "myinput[0].setAttribute('onkeyup', ""alert(Event.which || Event.keyCode)"");"
Self.ExecuteJavaScript(js)
The problem is that even though the keypress is ‘caught’, the elert shows undefined, so I can’t tell what key was pressed.
Even if I could tell what key was pressed, how could I call an xojo method.
To explain my ultimate goal/situation:
I’m using a web app as a custom user interface in SketchUp. I was using the textchange event to run a method that updates the drawing when the text field changes. The problem is that if users type to slow the update is done before they are done typing. Instead I now use the lostfocus event to only update when exiting the control. I also would like to be able to update the drawing by pressing {Enter}. The enter key fires my event in every other browser but not in the SketchUp WebDialog (I think it uses an older version of IE). I was told to use onkeyup event instead. This works with a plain HTML example but I haven’t been able to get it work in my Xojo app.