I'm trying to develop a class to ease input from data fields in a carbon NIB reference.
I set up the constructor, and everything worked perfectly.
When I tried to add a method to read input from a text field, I started getting errors.
The thing compiles, but the application shuts down and exits "with signal 6, SIGABRT"
here's the code:
Code:/* * carbonGraphicIO.h * * * Created by Erik Schmidt on 3/25/05. * Copyright 2005 Erik_Soft. All rights reserved. * * Provides eased IO capability within text field in a carbon application * * C++ version * */ #include <Carbon/Carbon.h> #include <sstream> #include <string> #include <cstring> using namespace std; class DataField { private: /*static ControlID ctrl; static CFStringRef textBuffer; static ostringstream textBufferConvert;*/ public: static ControlID ctrl; static CFStringRef textBuffer; static ostringstream textBufferConvert; DataField(ControlID ctr){ ctrl=ctr; }//end constructor pascal CFStringRef getCFStringData(WindowRef window){ ControlHandle dataField; GetControlByID(window,&ctrl,&dataField); return CFSTR("void"); }//end getCFStringData };//end class DataFieldAny ideas?Code:// // main.c // carbonGraphicIOTest // // Created by erik on 3/25/05. // Copyright __MyCompanyName__ 2005. All rights reserved. // #include <Carbon/Carbon.h> #include <iostream> #include "carbonGraphicIO.h" using namespace std; pascal OSStatus CGIOMainWindowEventHandler(EventHandlerCallRef handlerRef,EventRef event,void *userData); pascal void TestCommand(WindowRef window); int main(int argc, char* argv[]) { IBNibRef nibRef; WindowRef window; EventTypeSpec mainSpec={kEventClassCommand,kEventCommandProcess}; DataField inputTest((ControlID){129,'CGIO'}); DataField outputTest((ControlID){130,'CGIO'}); OSStatus err; // Create a Nib reference passing the name of the nib file (without the .nib extension) // CreateNibReference only searches into the application bundle. err = CreateNibReference(CFSTR("main"), &nibRef); require_noerr( err, CantGetNibRef ); // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar // object. This name is set in InterfaceBuilder when the nib is created. err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")); require_noerr( err, CantSetMenuBar ); // Then create a window. "MainWindow" is the name of the window object. This name is set in // InterfaceBuilder when the nib is created. err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window); require_noerr( err, CantCreateWindow ); // We don't need the nib reference anymore. DisposeNibReference(nibRef); InstallWindowEventHandler(window,NewEventHandlerUPP(CGIOMainWindowEventHandler),1,&mainSpec,(void *)window,NULL); // The window was created hidden so show it. ShowWindow( window ); // Call the event loop RunApplicationEventLoop(); CantCreateWindow: CantSetMenuBar: CantGetNibRef: return err; } pascal OSStatus CGIOMainWindowEventHandler(EventHandlerCallRef handlerRef,EventRef event,void *userData){ OSStatus err=eventNotHandledErr; HICommand command; GetEventParameter(event,kEventParamDirectObject,typeHICommand,NULL,sizeof(HICommand),NULL,&command); switch(command.commandID){ case 'tEst': TestCommand((WindowRef)userData); err=noErr; break; //end case }//end switch return err; }//end CGIOMainWindowEventHAndler pascal void TestCommand(WindowRef window){ //cout<<"test\n"; }//end TestCommand



LinkBack URL
About LinkBacks


