Added click-to-focus to GTK+ Areas and documented that click-to-focus happens; also TODOs related to that.

This commit is contained in:
Pietro Gagliardi 2014-04-14 23:11:28 -04:00
parent ef7b564855
commit da2d4da15a
4 changed files with 6 additions and 2 deletions

View File

@ -80,6 +80,7 @@ type MouseEvent struct {
// If the event was generated by a mouse button being pressed, Down contains the ID of that button.
// Otherwise, Down contains 0.
// If Down contains nonzero, the Area will also receive keyboard focus.
Down uint
// If the event was generated by a mouse button being released, Up contains the ID of that button.

View File

@ -141,6 +141,8 @@ func finishMouseEvent(widget *C.GtkWidget, data C.gpointer, me MouseEvent, mb ui
//export our_area_button_press_event_callback
func our_area_button_press_event_callback(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer) C.gboolean {
// clicking doesn't automatically transfer keyboard focus; we must do so manually (thanks tristan in irc.gimp.net/#gtk+)
C.gtk_widget_grab_focus(widget)
e := (*C.GdkEventButton)(unsafe.Pointer(event))
me := MouseEvent{
// GDK button ID == our button ID

View File

@ -622,7 +622,7 @@ func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lPara
}
return defwndproc()
case _WM_MOUSEACTIVATE:
// register our window for keyboard input
// transfer keyboard focus to our Area on an activating click
// (see http://www.catch22.net/tuts/custom-controls)
r1, _, err := _setFocus.Call(uintptr(s.hwnd))
if r1 == 0 { // failure

View File

@ -38,7 +38,8 @@ super ultra important things:
- resizing seems to be completely and totally broken in the Wayland backend
- TODO find out if this is a problem on the GTK+/Wayland side (no initial window-configure event?)
- redrawing controls after a window resize on Windows does not work properly
- clicking on Areas in GTK+ don't bring keyboard focus to them?
- test click to keyboard focus for Areas on Mac OS X
- make sure Areas get keyboard focus when clicking outside the actual Area space on all platforms
- make sure keyboard events on numpad off on all platforms don't switch between controls
- on Windows, Shift+(num pad key) triggers the shifted key code when num lock is off; will need to reorder key code tests on all platforms to fix this
- pressing global keycodes (including kwin's zoom in/out) when running the keyboard test in wine causes the Area to lose keyboard focus; this doesn't happen on the GTK+ version (fix the Windows version to behave like the GTK+ version)