He duplicado la clase get y le he renombrado a Sget luego le he cambiado las llamadas a las funciones de abajo.
Code: Select all
#import <Cocoa/Cocoa.h>
#define HB_DONT_DEFINE_BOOL
#include <hbapi.h>
#include <hbvm.h>
#include <fmsgs.h> // FiveMac messages
NSView * GetView( NSWindow * window );
static PHB_SYMB symFMH = NULL;
@interface SGet : NSSecureTextField
{
@public NSWindow * hWnd;
}
- (BOOL) textShouldEndEditing : ( NSText * ) text;
@end
@implementation SGet
- (BOOL) textShouldEndEditing : ( NSText * ) text
{
if( symFMH == NULL )
symFMH = hb_dynsymSymbol( hb_dynsymFindName( "_FMH" ) );
hb_vmPushSymbol( symFMH );
hb_vmPushNil();
hb_vmPushLong( ( LONG ) hWnd );
hb_vmPushLong( WM_GETVALID );
hb_vmPushLong( ( LONG ) self );
hb_vmDo( 3 );
return hb_parl( -1 );
}
@end
HB_FUNC( SGETCREATE )
{
SGet * edit = [ [ SGet alloc ]
initWithFrame : NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];
NSWindow * window = ( NSWindow * ) hb_parnl( 5 );
[ GetView( window ) addSubview : edit ];
edit->hWnd = window;
hb_retnl( ( LONG ) edit );
}
HB_FUNC( SGETSETTEXT )
{
NSSecureTextField * get = ( NSSecureTextField * ) hb_parnl( 1 );
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 2 ) ? hb_parc( 2 ) : "" ] autorelease ];
[ get setStringValue : string ];
}
HB_FUNC( SGETGETTEXT ) // hGet --> cText
{
NSSecureTextField * get = ( NSSecureTextField * ) hb_parnl( 1 );
NSString * string = [ get stringValue ];
hb_retc( [ string cStringUsingEncoding : NSASCIIStringEncoding ] );
}