コード例 #1
0
ファイル: input.go プロジェクト: jasonrpowers/glfw3
//SetKeyCallback sets the key callback which is called when a key is pressed,
//repeated or released.
//
//The key functions deal with physical keys, with layout independent key tokens
//named after their values in the standard US keyboard layout. If you want to
//input text, use the SetCharCallback instead.
//
//When a window loses focus, it will generate synthetic key release events for
//all pressed keys. You can tell these events from user-generated events by the
//fact that the synthetic ones are generated after the window has lost focus,
//i.e. Focused will be false and the focus callback will have already been
//called.
func (w *Window) SetKeyCallback(cbfun func(w *Window, key Key, scancode int, action Action, mods ModifierKey)) {
	if cbfun == nil {
		C.glfwSetKeyCallback(w.data, nil)
	} else {
		w.fKeyHolder = cbfun
		C.glfwSetKeyCallbackCB(w.data)
	}
}
コード例 #2
0
ファイル: input.go プロジェクト: godispy/glfw
// SetKeyCallback sets the key callback which is called when a key is pressed,
// repeated or released.
//
// The key functions deal with physical keys, with layout independent key tokens
// named after their values in the standard US keyboard layout. If you want to
// input text, use the SetCharCallback instead.
//
// When a window loses focus, it will generate synthetic key release events for
// all pressed keys. You can tell these events from user-generated events by the
// fact that the synthetic ones are generated after the window has lost focus,
// i.e. Focused will be false and the focus callback will have already been
// called.
func (w *Window) SetKeyCallback(cbfun KeyCallback) (previous KeyCallback) {
	previous = w.fKeyHolder
	w.fKeyHolder = cbfun
	if cbfun == nil {
		C.glfwSetKeyCallback(w.data, nil)
	} else {
		C.glfwSetKeyCallbackCB(w.data)
	}
	panicError()
	return previous
}