You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing a web browser for tracking user behaviour in usability testing. I've managed to collect mouse events but cannot get any key events in a Webview.
Some example code: The 'FrameOnKeyDown' function should print out "Key press" to the console when a key is pressed but, alas, this does not happen.
Does the Webview capture all key events and veto any further propagation? Menu shortcuts work okay when the Webview has focus so I think I've missed something important somewhere.
What is the best way to capture key events?
package main
import (
"fmt"
"github.com/dontpanic92/wxGo/wx"
)
// MainFrame Objects for the mainframe
type MainFrame struct {
wx.Frame
Webview wx.WebView
}
// Key catcher
func (f *MainFrame) FrameOnKeyDown(wx.Event) {
fmt.Println("Key press")
}
// NewFrame creates a new frame for the program
func NewFrame() *MainFrame {
f := &MainFrame{}
f.Frame = wx.NewFrame(wx.NullWindow, -1, "WebTrackly", wx.NewPointT(300, 100), wx.NewSizeT(800, 600), wx.DEFAULT_FRAME_STYLE|wx.WANTS_CHARS)
f.Frame.SetClientSize(wx.NewSizeT(800, 600))
f.Webview = wx.WebViewNew(f, wx.ID_ANY)
f.Webview.LoadURL("http://ddg.gg")
wx.Bind(f.Webview, wx.EVT_CHAR, f.FrameOnKeyDown, f.Webview.GetId())
wx.Bind(f.Webview, wx.EVT_KEY_UP, f.FrameOnKeyDown, f.Webview.GetId())
wx.Bind(f.Webview, wx.EVT_KEY_DOWN, f.FrameOnKeyDown, f.Webview.GetId())
return f
}
//Main Function
func main() {
wx1 := wx.NewApp("Webview test")
f := NewFrame()
f.Show()
wx1.MainLoop()
return
}
The text was updated successfully, but these errors were encountered:
I'm writing a web browser for tracking user behaviour in usability testing. I've managed to collect mouse events but cannot get any key events in a Webview.
Some example code: The 'FrameOnKeyDown' function should print out "Key press" to the console when a key is pressed but, alas, this does not happen.
Does the Webview capture all key events and veto any further propagation? Menu shortcuts work okay when the Webview has focus so I think I've missed something important somewhere.
What is the best way to capture key events?
The text was updated successfully, but these errors were encountered: