Skip to content

haptics ​

go
import "github.com/tangoui/tango/sys/haptics"

本页由 site/tools/apigen 从源码注释生成(按 darwin 构建标签选文件),请勿手改。

Package haptics plays haptic feedback: impacts, selection ticks and notification patterns (UIFeedbackGenerator on iOS, View.performHapticFeedback on Android, which needs no permission).

haptics.Play(a, haptics.Success)

Devices without a haptic engine (iPad, the iOS simulator, most desktops) silently do nothing; the call still succeeds where the API exists. Play returns ErrUnsupported where the backend has no haptics and tango.ErrNotRunning after the app quit. It does not wait for the pattern to finish.

常量 ​

go
const (
	Light     = platform.HapticLight  // light impact
	Medium    = platform.HapticMedium // medium impact
	Heavy     = platform.HapticHeavy  // heavy impact
	Selection = platform.HapticSelection
	Success   = platform.HapticSuccess
	Warning   = platform.HapticWarning
	Error     = platform.HapticError
)

变量 ​

go
var ErrUnsupported = platform.ErrUnsupported

函数 ​

func Play ​

go
func Play(a *tango.App, k Kind) error

Play plays k.

类型 ​

Kind ​

go
type Kind = platform.HapticKind

Kind is a feedback pattern.

以 MIT 许可发布