Projects

Ticket #105 (closed defect: fixed)

Opened 4 years ago

Last modified 14 months ago

BridgeSupport can't convert KCGSessionEventTap as an argument for CGEventTapCreate

Reported by: juanger@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.8
Component: MacRuby Keywords:
Cc:

Description

When running the following code:

eventTap = CGEventTapCreate(KCGSessionEventTap, KCGHeadInsertEventTap,
                               0, eventMask, @callback, nil)

It exits and displays the following error:

`CGEventTapCreate': can't convert Ruby object `1' to Objective-C value of type `^{__CGEventTapProxy=}' (ArgumentError)

Also, the callback function, passed as a lambda can't be converted.

Change History

Changed 3 years ago by lsansonetti@…

  • milestone changed from MacRuby 0.3 to MacRuby 0.4

Changed 14 months ago by mattaimonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from MacRuby 0.4 to MacRuby 0.8

Works fine now, here is how I tested the code above:

framework 'Cocoa' 
framework 'ApplicationServices'

@callback = proc{|a,b,c,d| puts 'callback'}

eventMask = 1 << KCGEventKeyDown
eventTap = CGEventTapCreate(KCGSessionEventTap, KCGHeadInsertEventTap,
                               0, eventMask, @callback, nil)

raise unless eventTap

run_loop_source = CFMachPortCreateRunLoopSource(KCFAllocatorDefault, eventTap, 0)
CFRunLoopAddSource(CFRunLoopGetCurrent(), run_loop_source, KCFRunLoopCommonModes)
CGEventTapEnable(eventTap, true)
CFRunLoopRun()
Note: See TracTickets for help on using tickets.