Keyboard Bug

Well I realy don’t know what this message says but…

2011-11-27 03:05:22.786 Corona Simulator[32653:903] HIToolbox: ignoring exception 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds' that raised inside Carbon event dispatch  
(  
 0 CoreFoundation 0x999586ca \_\_raiseError + 410  
 1 libobjc.A.dylib 0x99afb5a9 objc\_exception\_throw + 56  
 2 CoreFoundation 0x999583f8 +[NSException raise:format:arguments:] + 136  
 3 CoreFoundation 0x9995836a +[NSException raise:format:] + 58  
 4 Foundation 0x96a92b1e -[NSRLEArray objectAtIndex:effectiveRange:] + 118  
 5 Foundation 0x96a907ca -[NSConcreteMutableAttributedString replaceCharactersInRange:withString:] + 212  
 6 AppKit 0x98ae0591 -[NSConcreteTextStorage replaceCharactersInRange:withString:] + 102  
 7 AppKit 0x98b6f96a -[NSTextView insertText:replacementRange:] + 1701  
 8 AppKit 0x98b6d217 -[NSTextInputContext handleTSMEvent:] + 2657  
 9 AppKit 0x98b6c7a5 \_NSTSMEventHandler + 209  
 10 HIToolbox 0x94d73c2f \_ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1567  
 11 HIToolbox 0x94d72ef6 \_ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 411  
 12 HIToolbox 0x94d957f3 SendEventToEventTarget + 52  
 13 HIToolbox 0x94df79de SendTSMEvent + 82  
 14 HIToolbox 0x94df735b SendUnicodeTextAEToUnicodeDoc + 700  
 15 HIToolbox 0x94df6f65 TSMKeyEvent + 998  
 16 HIToolbox 0x94de7e32 TSMProcessRawKeyEvent + 2515  
 17 AppKit 0x98b6c084 -[NSTextInputContext handleEvent:] + 1453  
 18 AppKit 0x98b67ed1 -[NSView interpretKeyEvents:] + 209  
 19 AppKit 0x98b6b9a1 -[NSTextView keyDown:] + 751  
 20 AppKit 0x98a9cb28 -[NSWindow sendEvent:] + 5757  
 21 AppKit 0x989b560b -[NSApplication sendEvent:] + 6431  
 22 AppKit 0x98949253 -[NSApplication run] + 917  
 23 AppKit 0x98941289 NSApplicationMain + 574  
 24 Corona Simulator 0x00002d35 0x0 + 11573  
)  
2011-11-27 03:05:22.787 Corona Simulator[32653:903] Exception detected while handling key input.  
2011-11-27 03:05:22.787 Corona Simulator[32653:903] \*\*\* NSRunStorage, \_NSBlockNumberForIndex(): index (4294967295) beyond array bounds (0)  

So I get this message in my terminal when I tryed to write something in the field.
I don’t see any problem with keyboard but just in precaution I’m posting this

Ah… my code:

in main:

-- =============================== SALVANDO LOGIN =============================== --   
  
 local function resumeStart()  
 local path = system.pathForFile( "saveData3s.txt", system.DocumentsDirectory )   
 local file = io.open( path, "r" )  
  
 if file then  
 print("Loading our data...")  
 local contents = file:read( "\*a" )  
 -- Loads our data  
  
 local prevState = explode(", ", contents)  
  
 \_G.login = prevState[1]  
 \_G.senha = prevState[2]  
 \_G.nomeC = prevState[3]  
 \_G.emailC = prevState[4]  
 \_G.senhaC = prevState[5]  
  
 io.close( file )  
  
 else  
 \_G.login = "email"  
 \_G.senha = "senhasenhasenha"  
 \_G.nomeC = "nome"   
 \_G.emailC = "email"  
 \_G.senhaC = "senhasenhasenha"  
  
 end  
 end  
 -- Separates the variables into a table  
  
 local function onSystemEvent( event )  
 if( event.type == "applicationExit" ) then   
 local path = system.pathForFile( "saveData3.txt", system.DocumentsDirectory )   
 local file = io.open( path, "w+b" )  
 -- Creates the file where we save our data  
  
 file:write( \_G.login ..", ".. \_G.senha .. ", " .. \_G.nomeC .. ", " .. \_G.emailC .. ", " .. \_G.senhaC )  
 end  
 end  
 -- Saves our data  
  
  
  
  
 function explode(div,str)  
 if (div=='') then return false end  
 local pos,arr = 0,{}  
 -- for each divider found  
 for st,sp in function() return string.find(str,div,pos,true) end do  
 table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider  
 pos = sp + 1 -- Jump past current divider  
 end  
 table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider  
 return arr  
 end  
  
 local function loadSave()  
 -- start and resume from previous state, if any  
 resumeStart()   
  
 Runtime:addEventListener( "system", onSystemEvent )   
 end  
  
  
  
-- ========================================= FIM ============================================= --   
  
loadSave()   

in another lua file

LloginHandler = function(event)  
 if event.phase == "began" then  
 LloginField.text = ""  
  
 elseif event.phase == "ended" then  
 native.setKeyboardFocus( nil )  
  
 elseif event.phase == "submitted" then  
 native.setKeyboardFocus( LpasswordField )  
  
 end  
 end  
LloginField = native.newTextField( \_W/2 + 55, 180, 235, 40, LloginHandler )  
 LloginField.font = native.newFont( nil, 25 )  
 LloginField.text = \_G.login  
 LloginField.inputType = "email"  
 LloginField:setTextColor( 0, 84, 166 )  
 g:insert( LloginField )  

[import]uid: 23063 topic_id: 18274 reply_id: 318274[/import]

I forgot to say…

saveit = require "saveit"  

and this “saveit.lua”

module(..., package.seeall)  
  
function save( event )   
 local path = system.pathForFile( "saveData3.txt", system.DocumentsDirectory )   
 local file = io.open( path, "w+b" )  
 -- Creates the file where we save our data if needed  
  
 file:write( \_G.login ..", ".. \_G.senha .. ", " .. \_G.nomeC .. ", " .. \_G.emailC .. ", " .. \_G.senhaC )  
 io.close( file )  
 -- Saves our data  
  
 end  

[import]uid: 23063 topic_id: 18274 reply_id: 69991[/import]

Uploading testable code would be very useful.

For saving, switch from to using Ice - it’s much better and you can avoid globals :wink:

Peach :slight_smile: [import]uid: 52491 topic_id: 18274 reply_id: 70005[/import]

Can you point me to this “ice”?

Thanks [import]uid: 23063 topic_id: 18274 reply_id: 70028[/import]

Hi,

ICE?

Here you go --> http://developer.anscamobile.com/code/ice

PS: Sorry Peach, just trying to help. :slight_smile:

Cheers!

[import]uid: 89165 topic_id: 18274 reply_id: 70029[/import]

@Rodrigo RSCdev

Thank you Rodrigo RSCdev!

she will not mind… I guess hehehehe [import]uid: 23063 topic_id: 18274 reply_id: 70031[/import]

Haha, not at all - cheers Rodrigo!

Peach :slight_smile: [import]uid: 52491 topic_id: 18274 reply_id: 70099[/import]