[MacRuby-devel] Void pointers and userData

Kevin McGuinness kevin.mcguinness at gmail.com
Sat May 2 06:42:16 PDT 2009


Hi,

I'm wondering if it is possible to use the userData field of NSEvent in
MacRuby. I want to add tracking rectangles to a NSView subclass, and store
the object that is mouse has entered in the userData field. Something along
the lines of:

  addTrackingRect(rect, owner:self, userData:obj, assumeInside:false)

  ...

  def mouseEntered(event)
     obj = event.userData[0]
  end

However this produces the runtime error:

  can't convert C/Objective-C value `0x800418240' of type `ƿ_\377' to Ruby
  object (ArgumentError)

Is it possible to set the NSEvent userData field at all in MacRuby? I can
work around if not, but the userData field would be more efficient.

Thanks,
Kevin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20090502/b245c71e/attachment.html>


More information about the MacRuby-devel mailing list