summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-04-14 23:11:28 -0400
committerPietro Gagliardi <[email protected]>2014-04-14 23:11:28 -0400
commitda2d4da15a19887c1dd031314d61b1dc2b04ea6d (patch)
tree907aaceade5f51d24ee857916a26f8c4d2217743
parentef7b5648558d046ffa8739c46fa9a4aa4f637d24 (diff)
Added click-to-focus to GTK+ Areas and documented that click-to-focus happens; also TODOs related to that.
-rw-r--r--area.go1
-rw-r--r--area_unix.go2
-rw-r--r--area_windows.go2
-rw-r--r--todo.md3
4 files changed, 6 insertions, 2 deletions
diff --git a/area.go b/area.go
index c3c47da..b1d1b83 100644
--- a/area.go
+++ b/area.go
@@ -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.
diff --git a/area_unix.go b/area_unix.go
index 71a9edb..cfa5741 100644
--- a/area_unix.go
+++ b/area_unix.go
@@ -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
diff --git a/area_windows.go b/area_windows.go
index a2e8631..9db8091 100644
--- a/area_windows.go
+++ b/area_windows.go
@@ -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
diff --git a/todo.md b/todo.md
index c9b9e01..8926994 100644
--- a/todo.md
+++ b/todo.md
@@ -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)