inputmethodkit

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package inputmethodkit provides a fluent Go API over the macOS InputMethodKit framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IMKCandidatesOpacityAttributeName added in v0.8.0

func IMKCandidatesOpacityAttributeName() objc.ID

@const IMKCandidatesOpacityAttributeName @abstract The level of opacity. @discussion Value must be a NSNumber with a value from 0 to 1. IMKCandidatesOpacityAttributeName returns the string constant IMKCandidatesOpacityAttributeName as an objc.ID, for use as a dictionary key or selector argument.

func IMKCandidatesSendServerKeyEventFirst added in v0.8.0

func IMKCandidatesSendServerKeyEventFirst() objc.ID

@const IMKCandidatesSendServerKeyEventFirst @abstract Control when key events are sent to a candidate window. @discussion Value is a NSNumber with a boolean value of NO (key events are sent to the candidate window first) or YES (key events are sent to the IMKInputController first). Note that this is only applicable when a candidate window is displayed. The default behavior is to send the key event to the candidate window first, and if it is not processed there, to send it on to the input controller. IMKCandidatesSendServerKeyEventFirst returns the string constant IMKCandidatesSendServerKeyEventFirst as an objc.ID, for use as a dictionary key or selector argument.

func IMKControllerClass added in v0.8.0

func IMKControllerClass() objc.ID

@const IMKControllerClass @abstract Key used to find an input method's input controller class name from the input method's bundle. IMKControllerClass returns the string constant IMKControllerClass as an objc.ID, for use as a dictionary key or selector argument.

func IMKDelegateClass added in v0.8.0

func IMKDelegateClass() objc.ID

@const IMKDelegateClass @abstract Key used to find an input method's delegate class name from the input method's bundle. IMKDelegateClass returns the string constant IMKDelegateClass as an objc.ID, for use as a dictionary key or selector argument.

func IMKModeDictionary added in v0.8.0

func IMKModeDictionary() objc.ID

@const IMKModeDictionary @abstract Key used to obtain an input method's mode dictionary from the input method's bundle. IMKModeDictionary returns the string constant IMKModeDictionary as an objc.ID, for use as a dictionary key or selector argument.

func KIMKCommandClientName added in v0.8.0

func KIMKCommandClientName() objc.ID

@const kIMKCommandClient @abstract A client object that conforms to the IMKInputText and NSObject protocols. @discussion Use as a key to find the client in the infoDictionary. KIMKCommandClientName returns the string constant kIMKCommandClientName as an objc.ID, for use as a dictionary key or selector argument.

func KIMKCommandMenuItemName added in v0.8.0

func KIMKCommandMenuItemName() objc.ID

@const kIMKCommandMenuItem @abstract An NSMenuItem in the infoDictionary passed to menu item actions. @discussion Use as a key to find the NSMenuItem in the infoDictionary. KIMKCommandMenuItemName returns the string constant kIMKCommandMenuItemName as an objc.ID, for use as a dictionary key or selector argument.

Types

type Candidates

type Candidates struct {
	// contains filtered or unexported fields
}

The IMKCandidates class presents candidates to users and notifies the appropriate IMKInputController object when the user selects a candidate. Candidates are alternate characters for a given input sequence. The IMKCandidates class supports using a candidates window in your input method; using IMKCandidates is optional. Not all input methods require them.

Candidates wraps raw.IMKCandidates with a fluent Go API.

func CandidatesFromID

func CandidatesFromID(id objc.ID) *Candidates

CandidatesFromID adopts an existing object pointer as a Candidates (nil for 0).

func NewCandidatesWithServerPanelType

func NewCandidatesWithServerPanelType(server *raw.IMKServer, panelType uint) *Candidates

Returns the initialized IMKCandidates object.

NewCandidatesWithServerPanelType creates a new Candidates.

func NewCandidatesWithServerPanelTypeStyleType

func NewCandidatesWithServerPanelTypeStyleType(server *raw.IMKServer, panelType uint, style uint) *Candidates

NewCandidatesWithServerPanelTypeStyleType creates a new Candidates.

func (*Candidates) AttachChildToCandidateType

func (x *Candidates) AttachChildToCandidateType(child *raw.IMKCandidates, candidateIdentifier int, theType uint)

@method @abstract Attach an IMKCandidates object to the specified selection. @discussion The IMKCandidate can be a sublist or an annotation.

AttachChildToCandidateType calls the underlying AttachChildToCandidateType.

func (*Candidates) Attributes

func (x *Candidates) Attributes() *foundation.NSDictionary[objc.ID, objc.ID]

Returns a dictionary of the style attributes used for the candidates window..

Attributes calls the underlying Attributes.

func (*Candidates) CandidateFrame

func (x *Candidates) CandidateFrame() corefoundation.CGRect

CandidateFrame calls the underlying CandidateFrame.

func (*Candidates) CandidateIdentifierAtLineNumber

func (x *Candidates) CandidateIdentifierAtLineNumber(lineNumber int) int

@method @abstract Returns the candidate identifier for a given line in the candidate window display. @discussion Maps the lineNumber to a candidate identifier. Line number 0 corresponds to the candidate in the cell currently in the first (top for vertical) line of the candidate window. This is convienient for input methods that support selecting a candidate by a number key. Line Number values depend on the column arrangement of your candidate. If you are displaying a single column candidate window, lines that have been scrolled out of view will have negative values. For a single row grid line, numbers will correspond to the cell's position in the row (i.e. the first cell will be 0, the second 1, etc). Finally, for a grid, the line numbers correspond to the grid row. If the line number is invalid, NSNotFound is returned. @param lineNumber a number representing a cells position in the candidate window.

CandidateIdentifierAtLineNumber calls the underlying CandidateIdentifierAtLineNumber.

func (*Candidates) CandidateStringIdentifier

func (x *Candidates) CandidateStringIdentifier(candidateString objc.ID) int

@method @abstract Map a candidateString to an identifier. @discussion Beginning with MacOS 10.7, candidate strings are mapped internally to an unique identifier of type NSInteger. Using identifiers to identify a particular candidate is the first stage of enabling data types other than NSString and NSAttributedString for containing the contents of a candidate.

CandidateStringIdentifier calls the underlying CandidateStringIdentifier.

func (*Candidates) ClearSelection

func (x *Candidates) ClearSelection()

ClearSelection calls the underlying ClearSelection.

func (*Candidates) DetachChild

func (x *Candidates) DetachChild(candidateIdentifier int)

@method @abstract Detach the IMKCandidates object attached to candidate

DetachChild calls the underlying DetachChild.

func (*Candidates) DismissesAutomatically

func (x *Candidates) DismissesAutomatically() bool

Returns the state of the flag that determines whether the candidates window dismisses automatically.

DismissesAutomatically calls the underlying DismissesAutomatically.

func (*Candidates) Hide

func (x *Candidates) Hide()

Hides a candidates window, if it is visible.

Hide calls the underlying Hide.

func (*Candidates) HideChild

func (x *Candidates) HideChild()

@method @abstract If the current selection has a child IMKCandidates that is being shown hide it. @discussion Typically a client will not need to call this as IMKCandidates automatically hides and shows children.

HideChild calls the underlying HideChild.

func (*Candidates) ID

func (x *Candidates) ID() objc.ID

ID returns the underlying Objective-C object pointer (objc.ID), for passing to C APIs that take an object or CFTypeRef pointer.

func (*Candidates) IsVisible

func (x *Candidates) IsVisible() bool

Returns whether or not the candidates window is visible.

IsVisible calls the underlying IsVisible.

func (*Candidates) LineNumberForCandidateWithIdentifier

func (x *Candidates) LineNumberForCandidateWithIdentifier(candidateIdentifier int) int

@method @abstract Returns the line number for a given CandidateID. @result The line number. NSNotFound if the candidateID is invalid. @param candidateIdentifier - A valid identifier for a candidate. @discussion If the cell that contains the candidate is at the top line of the candidate window, the return value will be 0.

LineNumberForCandidateWithIdentifier calls the underlying LineNumberForCandidateWithIdentifier.

func (*Candidates) PanelType

func (x *Candidates) PanelType() uint

Returns the style of the candidates window.

PanelType calls the underlying PanelType.

func (*Candidates) SelectCandidate

func (x *Candidates) SelectCandidate(candidateIdentifier int)

SelectCandidate calls the underlying SelectCandidate.

func (*Candidates) SelectCandidateWithIdentifier

func (x *Candidates) SelectCandidateWithIdentifier(candidateIdentifier int) bool

@method @abstract Select the candidate whose identifier matches the identifier parameter. @result YES if the candidateIdentifier is valid an the selection was made. NO if canidateIdentifier is invalid or it was not possible make the selection. @param An identifier for a candidate. You can obtain an identifier by mapping a candidate to an identifier via the [IMKCandidates candidateStringIdentifier:].

SelectCandidateWithIdentifier calls the underlying SelectCandidateWithIdentifier.

func (*Candidates) SelectedCandidate

func (x *Candidates) SelectedCandidate() int

@method @abstract Returns the currently selected candidate identifer. @discussion Attempts to determine the identifier for the selected candidate. If there is no selection the return value will be NSNotFound.

SelectedCandidate calls the underlying SelectedCandidate.

func (*Candidates) SelectedCandidateString

func (x *Candidates) SelectedCandidateString() *foundation.NSAttributedString

@method @abstract Returns the currently selected candidate string. @discussion Attempts to determine the string for the selected candidate. If there is no selection the return value can be nil. The attributed string is an autoreleased object.

SelectedCandidateString calls the underlying SelectedCandidateString.

func (*Candidates) SelectionKeys

func (x *Candidates) SelectionKeys() *foundation.NSArray[objc.ID]

Returns an array of NSNumber objects where each NSNumber object represents a virtual key code.

SelectionKeys calls the underlying SelectionKeys.

func (*Candidates) SelectionKeysKeylayout

func (x *Candidates) SelectionKeysKeylayout() unsafe.Pointer

Returns the key layout that maps virtual key codes to selection keys.

SelectionKeysKeylayout calls the underlying SelectionKeysKeylayout.

func (*Candidates) SetAttributes

func (x *Candidates) SetAttributes(attributes *foundation.NSDictionary[objc.ID, objc.ID])

Sets the style attributes for the candidates window.

SetAttributes calls the underlying SetAttributes.

func (*Candidates) SetCandidateData

func (x *Candidates) SetCandidateData(candidatesArray *foundation.NSArray[objc.ID])

@method @abstract Set the candidates data directly rather than supplying data via [IMKInputContoller candidates:]. @discussion The elements of the array can be strings or attributed strings.

SetCandidateData calls the underlying SetCandidateData.

func (*Candidates) SetCandidateFrameTopLeft

func (x *Candidates) SetCandidateFrameTopLeft(point corefoundation.CGPoint)

@method @abstract Positions the top-left corner of the candidate window’s frame rectangle at a given point in screen coordinates.

SetCandidateFrameTopLeft calls the underlying SetCandidateFrameTopLeft.

func (*Candidates) SetDismissesAutomatically

func (x *Candidates) SetDismissesAutomatically(flag bool)

Sets the state of the flag that determines whether the candidates window dismisses automatically.

SetDismissesAutomatically calls the underlying SetDismissesAutomatically.

func (*Candidates) SetPanelType

func (x *Candidates) SetPanelType(panelType uint)

Sets the style of the candidates window.

SetPanelType calls the underlying SetPanelType.

func (*Candidates) SetSelectionKeys

func (x *Candidates) SetSelectionKeys(keyCodes *foundation.NSArray[objc.ID])

Sets the selection keys for the candidates.

SetSelectionKeys calls the underlying SetSelectionKeys.

func (*Candidates) SetSelectionKeysKeylayout

func (x *Candidates) SetSelectionKeysKeylayout(layout unsafe.Pointer)

Sets the key layout that is used to map virtual key codes to characters.

SetSelectionKeysKeylayout calls the underlying SetSelectionKeysKeylayout.

func (*Candidates) Show

func (x *Candidates) Show(locationHint uint)

Shows the candidates window.

Show calls the underlying Show.

func (*Candidates) ShowAnnotation

func (x *Candidates) ShowAnnotation(annotationString *foundation.NSAttributedString)

Displays an annotation string in an annotation window.

ShowAnnotation calls the underlying ShowAnnotation.

func (*Candidates) ShowCandidates

func (x *Candidates) ShowCandidates()

@method @abstract Show the candidate window. @discussion This simply shows the candidates. No effort is made to position the candidate. The caller should move the candidate window to an appropriate location prior to showing.

ShowCandidates calls the underlying ShowCandidates.

func (*Candidates) ShowChild

func (x *Candidates) ShowChild()

@method @abstract If the current selection has a child IMKCandidates object that will be shown. @discussion If there is a failure in showing the child this method will throw an exception.

ShowChild calls the underlying ShowChild.

func (*Candidates) ShowSublistSubListDelegate

func (x *Candidates) ShowSublistSubListDelegate(candidates *foundation.NSArray[objc.ID], delegate objc.ID)

ShowSublistSubListDelegate calls the underlying ShowSublistSubListDelegate.

func (*Candidates) Unwrap

func (x *Candidates) Unwrap() *raw.IMKCandidates

Unwrap returns the underlying raw.IMKCandidates.

func (*Candidates) UpdateCandidates

func (x *Candidates) UpdateCandidates()

Updates the candidates that are displayed in the candidates window.

UpdateCandidates calls the underlying UpdateCandidates.

type Candidatesable

type Candidatesable interface {
	Unwrap() *raw.IMKCandidates
	PanelType() uint
	SetPanelType(panelType uint)
	Show(locationHint uint)
	Hide()
	IsVisible() bool
	UpdateCandidates()
	ShowAnnotation(annotationString *foundation.NSAttributedString)
	ShowSublistSubListDelegate(candidates *foundation.NSArray[objc.ID], delegate objc.ID)
	CandidateFrame() corefoundation.CGRect
	SetSelectionKeys(keyCodes *foundation.NSArray[objc.ID])
	SelectionKeys() *foundation.NSArray[objc.ID]
	SetSelectionKeysKeylayout(layout unsafe.Pointer)
	SelectionKeysKeylayout() unsafe.Pointer
	SetAttributes(attributes *foundation.NSDictionary[objc.ID, objc.ID])
	Attributes() *foundation.NSDictionary[objc.ID, objc.ID]
	SetDismissesAutomatically(flag bool)
	DismissesAutomatically() bool
	SelectedCandidate() int
	SetCandidateFrameTopLeft(point corefoundation.CGPoint)
	ShowChild()
	HideChild()
	AttachChildToCandidateType(child *raw.IMKCandidates, candidateIdentifier int, theType uint)
	DetachChild(candidateIdentifier int)
	SetCandidateData(candidatesArray *foundation.NSArray[objc.ID])
	SelectCandidateWithIdentifier(candidateIdentifier int) bool
	SelectCandidate(candidateIdentifier int)
	ShowCandidates()
	CandidateStringIdentifier(candidateString objc.ID) int
	SelectedCandidateString() *foundation.NSAttributedString
	CandidateIdentifierAtLineNumber(lineNumber int) int
	LineNumberForCandidateWithIdentifier(candidateIdentifier int) int
	ClearSelection()
}

Candidatesable is the interface implemented by Candidates, for mocking and DI.

type InputController

type InputController struct {
	// contains filtered or unexported fields
}

The IMKInputController class provides a base class for custom input controller classes. The IMKServer class, which is allocated in the main function of an input method, creates an input controller object for each input session created by a client application. For every input session there is a corresponding IMKInputController object.

InputController wraps raw.IMKInputController with a fluent Go API.

func InputControllerFromID

func InputControllerFromID(id objc.ID) *InputController

InputControllerFromID adopts an existing object pointer as a InputController (nil for 0).

func NewInputControllerWithServerDelegateClient

func NewInputControllerWithServerDelegateClient(server *raw.IMKServer, delegate objc.ID, inputClient objc.ID) *InputController

Initializes the input control by setting the delegate.

NewInputControllerWithServerDelegateClient creates a new InputController.

func (*InputController) AnnotationSelectedForCandidate

func (x *InputController) AnnotationSelectedForCandidate(annotationString *foundation.NSAttributedString, candidateString *foundation.NSAttributedString)

Sends the selected candidate string and annotation string to the input controller.

AnnotationSelectedForCandidate calls the underlying AnnotationSelectedForCandidate.

func (*InputController) CancelComposition

func (x *InputController) CancelComposition()

Stops the current composition and replaces marked text with the original text.

CancelComposition calls the underlying CancelComposition.

func (*InputController) CandidateSelected

func (x *InputController) CandidateSelected(candidateString *foundation.NSAttributedString)

Informs an input controller that a new candidate is selected.

CandidateSelected calls the underlying CandidateSelected.

func (*InputController) CandidateSelectionChanged

func (x *InputController) CandidateSelectionChanged(candidateString *foundation.NSAttributedString)

Informs an input controller that the current candidate selection in the candidate window has changed.

CandidateSelectionChanged calls the underlying CandidateSelectionChanged.

func (*InputController) Client

func (x *InputController) Client() objc.ID

Returns the client object associated with the input controller.

Client calls the underlying Client.

func (*InputController) CompositionAttributesAtRange

func (x *InputController) CompositionAttributesAtRange(range_ foundation.NSRange) *foundation.NSMutableDictionary[objc.ID, objc.ID]

Returns a dictionary of text attributes.

CompositionAttributesAtRange calls the underlying CompositionAttributesAtRange.

func (*InputController) Delegate

func (x *InputController) Delegate() objc.ID

Returns the delegate for input controller object.

Delegate calls the underlying Delegate.

func (*InputController) DoCommandBySelectorCommandDictionary

func (x *InputController) DoCommandBySelectorCommandDictionary(aSelector objc.SEL, infoDictionary *foundation.NSDictionary[objc.ID, objc.ID])

Passes commands that are not generated as part of the text input process.

DoCommandBySelectorCommandDictionary calls the underlying DoCommandBySelectorCommandDictionary.

func (*InputController) HidePalettes

func (x *InputController) HidePalettes()

Informs an input method that it should close any visible user interface.

HidePalettes calls the underlying HidePalettes.

func (*InputController) ID

func (x *InputController) ID() objc.ID

ID returns the underlying Objective-C object pointer (objc.ID), for passing to C APIs that take an object or CFTypeRef pointer.

func (*InputController) InputControllerWillClose

func (x *InputController) InputControllerWillClose()

@method @abstract Called to notify an input controller that it is about to be closed.

InputControllerWillClose calls the underlying InputControllerWillClose.

func (*InputController) MarkForStyleAtRange

func (x *InputController) MarkForStyleAtRange(style int, range_ foundation.NSRange) *foundation.NSDictionary[objc.ID, objc.ID]

Returns a dictionary of text attributes that can mark a range of an attributed string to send to a client.

MarkForStyleAtRange calls the underlying MarkForStyleAtRange.

func (*InputController) Menu

func (x *InputController) Menu() *appkit.NSMenu

Returns a menu of commands that are specific to an input method.

Menu calls the underlying Menu.

func (*InputController) ReplacementRange

func (x *InputController) ReplacementRange() foundation.NSRange

Returns the range in the client document that the text should replace.

ReplacementRange calls the underlying ReplacementRange.

func (*InputController) SelectionRange

func (x *InputController) SelectionRange() foundation.NSRange

Returns where the range of the selection that should be placed inside marked text.

SelectionRange calls the underlying SelectionRange.

func (*InputController) Server

func (x *InputController) Server() *Server

Returns the server object that manages the input controller.

Server calls the underlying Server.

func (*InputController) SetDelegate

func (x *InputController) SetDelegate(newDelegate objc.ID)

Sets the delegate for input controller object.

SetDelegate calls the underlying SetDelegate.

func (*InputController) Unwrap

func (x *InputController) Unwrap() *raw.IMKInputController

Unwrap returns the underlying raw.IMKInputController.

func (*InputController) UpdateComposition

func (x *InputController) UpdateComposition()

Informs the input controller that the composition has changed.

UpdateComposition calls the underlying UpdateComposition.

type InputControllerable

type InputControllerable interface {
	Unwrap() *raw.IMKInputController
	UpdateComposition()
	CancelComposition()
	CompositionAttributesAtRange(range_ foundation.NSRange) *foundation.NSMutableDictionary[objc.ID, objc.ID]
	SelectionRange() foundation.NSRange
	ReplacementRange() foundation.NSRange
	MarkForStyleAtRange(style int, range_ foundation.NSRange) *foundation.NSDictionary[objc.ID, objc.ID]
	DoCommandBySelectorCommandDictionary(aSelector objc.SEL, infoDictionary *foundation.NSDictionary[objc.ID, objc.ID])
	HidePalettes()
	Menu() *appkit.NSMenu
	Delegate() objc.ID
	SetDelegate(newDelegate objc.ID)
	Server() *Server
	Client() objc.ID
	InputControllerWillClose()
	AnnotationSelectedForCandidate(annotationString *foundation.NSAttributedString, candidateString *foundation.NSAttributedString)
	CandidateSelectionChanged(candidateString *foundation.NSAttributedString)
	CandidateSelected(candidateString *foundation.NSAttributedString)
}

InputControllerable is the interface implemented by InputController, for mocking and DI.

type Server

type Server struct {
	// contains filtered or unexported fields
}

The IMKServer class manages client connections to your input method. When you write the main function for your input method, you create an IMKServer object. You should never need to override this class.

Server wraps raw.IMKServer with a fluent Go API.

func NewServerWithNameBundleIdentifier

func NewServerWithNameBundleIdentifier(name string, bundleIdentifier string) *Server

Creates and returns a server object from property list information contained in the provided bundle.

NewServerWithNameBundleIdentifier creates a new Server.

func NewServerWithNameControllerClassDelegateClass

func NewServerWithNameControllerClassDelegateClass(name string, controllerClassID objc.Class, delegateClassID objc.Class) *Server

Creates and returns a server object initialized with the provided parameters.

NewServerWithNameControllerClassDelegateClass creates a new Server.

func ServerFromID

func ServerFromID(id objc.ID) *Server

ServerFromID adopts an existing object pointer as a Server (nil for 0).

func (*Server) Bundle

func (x *Server) Bundle() *foundation.NSBundle

Returns an NSBundle object for the input method.

Bundle calls the underlying Bundle.

func (*Server) ID

func (x *Server) ID() objc.ID

ID returns the underlying Objective-C object pointer (objc.ID), for passing to C APIs that take an object or CFTypeRef pointer.

func (*Server) LastKeyEventWasDeadKey

func (x *Server) LastKeyEventWasDeadKey() bool

@method @abstract Returns a BOOL indicating whether or not the last key press was a dead key.

LastKeyEventWasDeadKey calls the underlying LastKeyEventWasDeadKey.

func (*Server) PaletteWillTerminate

func (x *Server) PaletteWillTerminate() bool

@method @abstract Call this before terminating a palette IM. @discussion Palettes need to be able to terminate. When this method is called the IMKServer will notify each client of the palette that the palette is about to terminate. The palette can terminate safely if a value of YES is returned. If the caller of this method is not an input method of type palette an exception will be thrown. If the method returns NO the palette should not terminate.

PaletteWillTerminate calls the underlying PaletteWillTerminate.

func (*Server) Unwrap

func (x *Server) Unwrap() *raw.IMKServer

Unwrap returns the underlying raw.IMKServer.

type Serverable

type Serverable interface {
	Unwrap() *raw.IMKServer
	Bundle() *foundation.NSBundle
	PaletteWillTerminate() bool
	LastKeyEventWasDeadKey() bool
}

Serverable is the interface implemented by Server, for mocking and DI.

Jump to

Keyboard shortcuts

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