Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 15, 2010, 09:27 AM   #1
MACaveli7
macrumors newbie
 
Join Date: Oct 2010
Param error in UCKeyTranslate()

Does anyone know why the below code is causing UCKeyTranslate to return an error?

const int kBuffSize = 16;

MacTypes::TSMDocumentID idocID;

MacTypes::OSType types[1];
types[0] = MacTypes::kUnicodeDocument;

MacTypes::NewTSMDocument(1, types, &idocID,0);

const MacTypes::UCKeyboardLayout* uchrHandle;
MacTypes::UInt32 deadKeyState = 0;
MacTypes::SInt16 currentKeyScript;
MacTypes::SInt16 lastKeyLayoutID;
MacTypes::UniChar unicodeInputString[kBuffSize];

MacTypes::UInt32 keyboardType;
MacTypes::UInt32 modifierKeyState;
MacTypes::UInt16 virtualKeyCode;
MacTypes::UInt16 keyAction;
MacTypes::UniCharCount actualStringLength;

keyAction = MacTypes::kUCKeyActionDown;
modifierKeyState = 0;
keyboardType = MacTypes::LMGetKbdType();

currentKeyScript = GetScriptManagerVariable(MacTypes::smKeyScript);

lastKeyLayoutID = GetScriptVariable(currentKeyScript, MacTypes::smScriptKeys);

//uchrHandle = MacTypes::GetResource('uchr', lastKeyLayoutID);
uchrHandle = (const MacTypes::UCKeyboardLayout*)MacTypes::GetResource('uchr', 0);

if (uchrHandle)
{
MacTypes::OSStatus status = MacTypes::UCKeyTranslate(uchrHandle, uVirtualKey,keyAction, modifierKeyState, keyboardType, 0, &deadKeyState,
kBuffSize, &actualStringLength, unicodeInputString);
}
MACaveli7 is offline   0 Reply With Quote
Old Oct 15, 2010, 12:34 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
Which error is it returning?

What have you already tried to debug this?
chown33 is offline   0 Reply With Quote
Old Oct 17, 2010, 04:55 AM   #3
MACaveli7
Thread Starter
macrumors newbie
 
Join Date: Oct 2010
It is returning a param error (-50), I think it is because the second parameter of the GetResource function is set to zero. I set it to zero because when I used 'lastKeyLayoutID', uchr returned 'invalid'. I'm assuming that in that case I should use the KCHR resource for ascii input instead. So the question is why don't I have the 'uchr' resource for the lastKeyLayoutID on my machine, this question might seem niave but I am a newbie to Mac programming.
MACaveli7 is offline   0 Reply With Quote
Old Oct 18, 2010, 01:23 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
If you're new to Mac programming, what are you trying to accomplish that needs keycode transformation into Unicode?

Have you seen these:
http://www.cocoabuilder.com/archive/...de-string.html
http://lists.apple.com/archives/Carb.../msg00012.html
chown33 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
The operation canít be completed because an unexpected error occurred (error code -50 Hexley OS X Mavericks (10.9) 6 May 21, 2014 02:16 AM
iPhone: [Help] Winterboard error "There was an error loading the preference bundle for winter becast Jailbreaks and iOS Hacks 10 Feb 28, 2014 09:58 PM
Network users login error 'can't log in at this time due to an error' RyanelRichie Mac OS X 10.7 Lion 1 Jan 8, 2014 04:29 AM
-fobjc-arc is not supported error and duplicate symbol error in compiling mehdies Mac Programming 3 Sep 24, 2013 01:57 AM
Cydia mismatch error, and indexed files failed to load error. Napster100 Jailbreaks and iOS Hacks 6 May 19, 2013 01:31 PM

Forum Jump

All times are GMT -5. The time now is 07:30 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC