Instance Method

didCommand(by:client:)

Processes a command generated by user action such as typing certain keys or pressing the mouse button.

Declaration

func didCommand(by aSelector: Selector!, client sender: Any!) -> Bool

Parameters

aSelector

The action associated with the key down event. The selector can be an action specified in the input method dictionary of keys and actions (that is, an action specific to the input method) or one of the NSResponder action methods such as insertNewline: or deleteBackward:. By definition such action methods do not return a value.

sender

The client object sending the key down event.

Return Value

true if the command is handled; false if the command is not handled. If not handled, the event passes to the client.

Discussion

This method is called when the system binds a key down event to an action method. If you implement this method you should test if it is appropriate to call the action method before actually calling it, because calling the action method implies that you agree to handle the command. Suppose you have implemented a version of insertNewline: that terminates the conversion session and sends the fully converted text to the client. However, if you conversion buffer is empty, you want the application to receive the return key that triggered the call to insertNewline:. In that case, when didCommandBySelector:client: is called you should test your buffer before calling your implementation of insertNewline:. If the buffer is empty, return false to indicate that the return key should be passed on to the application. If the buffer is not empty, call insertNewline: and then return true as the result of didCommandBySelector:client:.

See Also

Supporting Key Binding

func inputText(String!, client: Any!) -> Bool

Handles key down events that do not map to an action method.