[futurebasic] Re: [FB] Change cursor by bundle image

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2011 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Sun, 5 Jun 2011 18:46:40 +0100
Yoshiyuki wrote:

> Please add the method of specifying "Images" folder that puts the cursor image.

If I've misunderstood the request, please file this accordingly.
'---------------
// Compile as Objective-C

include resources "Images" // folder containing image file

toolbox fn NSApplicationLoad = Boolean
fn NSApplicationLoad()

BeginCDeclaration
void ChangeCursor( CFStringRef name, CFStringRef extension, CFStringRef subdirectory );
EndC

BeginCFunction
void ChangeCursor( CFStringRef name, CFStringRef extension, CFStringRef subdirectory )
{
     NSURL *url = [[NSBundle mainBundle] URLForResource:(NSString *)name withExtension:(NSString *)extension subdirectory:(NSString *)subdirectory];
     NSImage *image = [[NSImage alloc] initWithContentsOfURL:(NSURL *)url];
     NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint( 6, 6 )];
     [image release];
     [cursor set];
     [cursor release];
}
EndC
toolbox ChangeCursor( CFStringRef name, CFStringRef extension, CFStringRef subdirectory )

local fn DoDialog
'~'1
long if ( dialog(0) == _btnClick )
ChangeCursor( @"CrossPointCursor", @"png", @"Images" )
end if
end fn

window 1
button 1,,"Change Cursor",(20,20)-(140,40)

on dialog fn DoDialog

RunApplicationEventLoop()
'---------------

Bernie