My apologies, I sent some code without reading it carefully first.=20
Both of the *EXT.py imports are categories that I added to PyObjC
which were needed for that code, but not for a minimal example. Sorry
for that.
I wasn't able to get your test case to show the hand cursor at first,
but tweaked it until it did. Unfortunately, I have not been able to
get a large cursor to display. It works fine in an app I've built,
but I can't get it to work in the small test app, and I can't see what
is different. I've tried setting the cursor after the application has
loaded, tried saving the cursor image to a file to make sure the image
is real, tried building the testcase as an app using py2app. I've
added a custom view which supports invalidateCursorRectsForView:,
which is how my app works. Still nothing--the cursor just disappears
when it is over the test app.
I've also tried making the image 16x16 and it still fails, also the
cursor image from a file. So there's something else going wrong.
The oddest part is that I haven't had any trouble with the cursor
before (that I can recall). I didn't know it was hard. One thing I
haven't tried is loading the window from a Nib. I don't know why that
would effect it, but sometimes OS X is funny that way. If you're
interested, here is what I've got:
from AppKit import *
from PyObjCTools import AppHelper
class MyAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, notification):
win =3D NSApp().windows()[0]
win.invalidateCursorRectsForView_(win.contentView())
class MyView(NSView):
def resetCursorRects(self):
cursor =3D getCursor()
#cursor =3D NSCursor.disappearingItemCursor()
self.addCursorRect_cursor_(self.visibleRect(), cursor)
def getCursor():
cursor_size =3D [16,16]
cursor_rect =3D ((0,0),cursor_size)
cursor_centre =3D [8,8]
cursor_image =3D NSImage.alloc().initWithContentsOfFile_('circle.tiff')
#cursor_image =3D NSImage.alloc().initWithSize_(cursor_size)
#cursor_image.lockFocus()
#NSColor.yellowColor().set()
#NSBezierPath.bezierPathWithOvalInRect_(cursor_rect)
#cursor_image.unlockFocus()
return NSCursor.alloc().initWithImage_hotSpot_(cursor_image, cursor_cen=
tre)
if __name__ =3D=3D "__main__":
app =3D NSApplication.sharedApplication()
delegate =3D MyAppDelegate.alloc().init()
app.setDelegate_(delegate)
win =3D NSWindow.alloc().\
initWithContentRect_styleMask_backing_defer_(
((100, 100), (300, 300)),
NSTitledWindowMask,
NSBackingStoreBuffered,
True)
view =3D MyView.alloc().initWithFrame_(((0,0),(260,260)))
win.setContentView_(view)
win.makeKeyAndOrderFront_(win)
AppHelper.runEventLoop()
|