Instance Method

didCommandBySelector:client:

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

Declaration

- (BOOL)didCommandBySelector:(SEL)aSelector client:(id)sender;

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

YES if the command is handled; NO 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 NO to indicate that the return key should be passed on to the application. If the buffer is not empty, call insertNewline: and then return YES as the result of didCommandBySelector:client:.

See Also

Supporting Key Binding

- inputText:client:

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