diff --git a/darwin/app_kit.nim b/darwin/app_kit.nim index b04dfa6..24d8a1b 100644 --- a/darwin/app_kit.nim +++ b/darwin/app_kit.nim @@ -3,11 +3,11 @@ import app_kit / [nsscreen, nsview, nsevent, nscursor, nspasteboard, nswindow, nsapplication, nsmenu, nsresponder, nstext, nstextview, nswindowcontroller, nsdragoperation, nsdragginginfo, nsalert, nsimage, nscell, nscontrol, nsfont, nstextfield, nscolor, nsimageview, nspanel, nssavepanel, - nsopenpanel, nsbutton] + nsopenpanel, nsbutton, nseventmask] export foundation, nsscreen, nsview, nsevent, nscursor, nspasteboard, nswindow, nsapplication, nsmenu, nsresponder, nstext, nstextview, nswindowcontroller, nsdragoperation, nsdragginginfo, nsalert, nsimage, nscell, nscontrol, nsfont, nstextfield, nscolor, nsimageview, nspanel, nssavepanel, - nsopenpanel, nsbutton + nsopenpanel, nsbutton, nseventmask {.passL: "-framework AppKit".} diff --git a/darwin/app_kit/nsapplication.nim b/darwin/app_kit/nsapplication.nim index 4cc42b3..feeb548 100644 --- a/darwin/app_kit/nsapplication.nim +++ b/darwin/app_kit/nsapplication.nim @@ -59,4 +59,6 @@ proc stopModal*(self: NSApplication) {.objc: "stopModal".} # Abort a specific modal session proc abortModal*(self: NSApplication) {.objc: "abortModal".} -proc setDelegate*(s: NSApplication, d: NSObject) {.objc: "setDelegate:".} \ No newline at end of file +proc setDelegate*(s: NSApplication, d: NSObject) {.objc: "setDelegate:".} + +proc sendAction*(s: NSApplication, a: SEL, to: ID, `from`: ID): BOOL {.objc: "sendAction:to:from:".} \ No newline at end of file diff --git a/darwin/app_kit/nsevent.nim b/darwin/app_kit/nsevent.nim index deff3e3..3bff7af 100644 --- a/darwin/app_kit/nsevent.nim +++ b/darwin/app_kit/nsevent.nim @@ -1,6 +1,7 @@ -import ../objc/runtime +import ../objc/[runtime, blocks] import ../core_graphics/cggeometry import ../foundation/[nsgeometry, nsstring, nsdate] +import ./nseventmask type NSEvent* = ptr object of NSObject @@ -86,3 +87,4 @@ proc mouseEventWithType*(self: typedesc[NSEvent], eventType: NSEventKind, locati buttonNumber: NSInteger, clickCount: NSInteger, pressure: CGFloat): NSEvent {.objc: "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:buttonNumber:clickCount:pressure:".} proc charactersIgnoringModifiers*(self: NSEvent): NSString {.objc: "charactersIgnoringModifiers".} +proc addLocalMonitorForEventsMatchingMask*(self: typedesc[NSEvent], mask: NSEventMask, handler: Block[proc (e: NSEvent): NSEvent]):ID {.objc: "addLocalMonitorForEventsMatchingMask:handler:", discardable.} diff --git a/darwin/app_kit/nseventmask.nim b/darwin/app_kit/nseventmask.nim new file mode 100644 index 0000000..2aa02c1 --- /dev/null +++ b/darwin/app_kit/nseventmask.nim @@ -0,0 +1,18 @@ +type + NSEventMask* {.size: sizeof(uint64).} = enum + LeftMouseDown = 1 shl 1, + LeftMouseUp = 1 shl 2, + RightMouseDown = 1 shl 3, + RightMouseUp = 1 shl 4, + MouseMoved = 1 shl 5, + LeftMouseDragged = 1 shl 6, + RightMouseDragged = 1 shl 7, + KeyDown = 1 shl 10, + KeyUp = 1 shl 11, + FlagsChanged = 1 shl 12, + ScrollWheel = 1 shl 22, + TabletPoint = 1 shl 23, + TabletProximity = 1 shl 24, + OtherMouseDown = 1 shl 25, + OtherMouseUp = 1 shl 26, + OtherMouseDragged = 1 shl 27