Added click-to-focus to GTK+ Areas and documented that click-to-focus happens; also TODOs related to that.
This commit is contained in:
parent
ef7b564855
commit
da2d4da15a
1
area.go
1
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.
|
// If the event was generated by a mouse button being pressed, Down contains the ID of that button.
|
||||||
// Otherwise, Down contains 0.
|
// Otherwise, Down contains 0.
|
||||||
|
// If Down contains nonzero, the Area will also receive keyboard focus.
|
||||||
Down uint
|
Down uint
|
||||||
|
|
||||||
// If the event was generated by a mouse button being released, Up contains the ID of that button.
|
// If the event was generated by a mouse button being released, Up contains the ID of that button.
|
||||||
|
|
|
@ -141,6 +141,8 @@ func finishMouseEvent(widget *C.GtkWidget, data C.gpointer, me MouseEvent, mb ui
|
||||||
|
|
||||||
//export our_area_button_press_event_callback
|
//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 {
|
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))
|
e := (*C.GdkEventButton)(unsafe.Pointer(event))
|
||||||
me := MouseEvent{
|
me := MouseEvent{
|
||||||
// GDK button ID == our button ID
|
// GDK button ID == our button ID
|
||||||
|
|
|
@ -622,7 +622,7 @@ func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lPara
|
||||||
}
|
}
|
||||||
return defwndproc()
|
return defwndproc()
|
||||||
case _WM_MOUSEACTIVATE:
|
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)
|
// (see http://www.catch22.net/tuts/custom-controls)
|
||||||
r1, _, err := _setFocus.Call(uintptr(s.hwnd))
|
r1, _, err := _setFocus.Call(uintptr(s.hwnd))
|
||||||
if r1 == 0 { // failure
|
if r1 == 0 { // failure
|
||||||
|
|
3
todo.md
3
todo.md
|
@ -38,7 +38,8 @@ super ultra important things:
|
||||||
- resizing seems to be completely and totally broken in the Wayland backend
|
- 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?)
|
- 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
|
- 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
|
- 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
|
- 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)
|
- 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)
|
||||||
|
|
Loading…
Reference in New Issue