Instance Method


Returns the next event matching a given mask.


func nextEvent(matching mask: NSEvent.EventTypeMask) -> NSEvent?



The mask that the event to return must match. Events with non-matching masks are left in the queue. See discardEvents(matching:before:) in NSApplication for the list of mask values.

Return Value

The next event whose mask matches mask; nil when no matching event was found.


This method calls the nextEvent(matching:until:inMode:dequeue:) method, where the matching mask parameter is the specified mask, the until parameter is distantFuture, the inMode parameter is eventTracking, and the dequeue parameter is true.

See Also

Handling Events

class func menuChanged(NSMenu)

This method does nothing; it is here for backward compatibility.

var currentEvent: NSEvent?

The event currently being processed by the application.

func discardEvents(matching: NSEvent.EventTypeMask, before: NSEvent?)

Forwards the message to the NSApplication object, NSApp.

func postEvent(NSEvent, atStart: Bool)

Forwards the message to the global NSApplication object, NSApp.

func sendEvent(NSEvent)

This action method dispatches mouse and keyboard events sent to the window by the NSApplication object.

func tryToPerform(Selector, with: Any?) -> Bool

Dispatches action messages with a given argument.