keybinder

package module
v0.0.0-...-b57cb37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2017 License: MIT Imports: 4 Imported by: 1

README

go-keybinder GoDoc

The go-keybinder project provides Go bindings for keybinder-3.0.

Sample Use

The following example can be found in Examples.

package main

import (
	"log"
	"unsafe"

	"github.com/Isolus/go-keybinder"
	"github.com/gotk3/gotk3/glib"
	"github.com/gotk3/gotk3/gtk"
)

var win *gtk.Window

func keybinderHandler(keystring string, data unsafe.Pointer) {

	if win.IsVisible() {
		glib.IdleAdd(win.Hide)
	} else {
		glib.IdleAdd(win.Show)
	}
	log.Printf("Pressed: %s", keystring)
}

func main() {
	// Initialize GTK without parsing any command line arguments.
	gtk.Init(nil)

	keybinder.Init()
	keybinder.Bind("<Ctrl>space", keybinderHandler, nil)

	// Create a new toplevel window, set its title, and connect it to the
	// "destroy" signal to exit the GTK main loop when it is destroyed.
	var err error
	win, err = gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Unable to create window:", err)
	}
	win.SetTitle("Simple Example")
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	// Create a new label widget to show in the window.
	l, err := gtk.LabelNew("Hello, gotk3!")
	if err != nil {
		log.Fatal("Unable to create label:", err)
	}

	// Add the label to the window.
	win.Add(l)

	// Set the default window size.
	win.SetDefaultSize(800, 600)

	// Recursively show all widgets contained in this window.
	win.ShowAll()

	// Begin executing the GTK main loop.  This blocks until
	// gtk.MainQuit() is run.
	gtk.Main()
}

To build the example:

$ go build example.go

Documentation

The internal go doc style documentation can be viewed online without installing this package by using the GoDoc site.

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/Isolus/go-keybinder

Installation

go-keybinder currently requires keybinder-3.0. A recent Go is also required.

TODO

  • Add bindings for keybinder_bind_full().

License

Package go-keybinder is licensed under the MIT License.

Documentation

Overview

Go bindings for keybinder-3.0.

Functions use the same names as the native C function calls, but use CamelCase.

The keybinder-3.0 documentation can be very useful for understanding how the functions in this package work. This documentation can be found at https://github.com/kupferlauncher/keybinder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(keystring string, cb KeybinderHandler, data unsafe.Pointer) bool

Bind() is a wrapper around keybinder_bind().

func GetCurrentEventTime

func GetCurrentEventTime() uint32

GetCurrentEventTime() is a wrapper around keybinder_get_current_event_time().

func Init

func Init()

Init() is a wrapper around keybinder_init().

func SetUseCookedAccelerators

func SetUseCookedAccelerators(cooked bool)

SetUseCookedAccelerators() is a wrapper around keybinder_set_use_cooked_accelerators().

func Supported

func Supported() bool

Supported() is a wrapper around keybinder_supported().

func Unbind

func Unbind(keystring string, handler KeybinderHandler)

Unbind() is a wrapper around keybinder_unbind().

func UnbindAll

func UnbindAll(keystring string)

UnbindAll() is a wrapper around keybinder_unbind_all().

Types

type KeybinderHandler

type KeybinderHandler func(keystring string, userData unsafe.Pointer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL