add mouse toggle return and add more test

This commit is contained in:
vcaesar 2020-03-16 13:51:46 -04:00
parent b5d72b8d18
commit bec66ba51f
2 changed files with 11 additions and 2 deletions

View File

@ -510,7 +510,7 @@ func MovesClick(x, y int, args ...interface{}) {
}
// MouseToggle toggle the mouse
func MouseToggle(togKey string, args ...interface{}) {
func MouseToggle(togKey string, args ...interface{}) int {
var button C.MMMouseButton = C.LEFT_BUTTON
if len(args) > 0 {
@ -518,9 +518,10 @@ func MouseToggle(togKey string, args ...interface{}) {
}
down := C.CString(togKey)
C.mouse_toggle(down, button)
i := C.mouse_toggle(down, button)
C.free(unsafe.Pointer(down))
return int(i)
}
// ScrollMouse scroll the mouse

View File

@ -97,6 +97,11 @@ func TestMoveSmoothRelative(t *testing.T) {
tt.Equal(t, 190, y)
}
func TestMouseToggle(t *testing.T) {
e := MouseToggle("up", "right")
tt.Zero(t, e)
}
func TestKey(t *testing.T) {
e := KeyTap("v", "cmd")
tt.Empty(t, e)
@ -120,6 +125,9 @@ func TestTypeStr(t *testing.T) {
e := PasteStr("s")
tt.Empty(t, e)
uc := toUC("s")
tt.Equal(t, "[s]", uc)
}
func TestKeyCode(t *testing.T) {