Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Performance issues - composer.gotoScene and text listener
Started by bbk Jan 11 2018 07:59 AM

- - - - -
No replies to this topic
gotoscene textlistener string.find
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

bbk

[GLOBAL: userInfoPane.html]
bbk
  • Enthusiast

  • 61 posts
  • Corona SDK

Sorry, I have two questions in one.

 

We are developing a business App and I am experiencing performance issues.

 

One is when I change scene and at times I experience that the previous scene remains on the screen (I can see half of it) and the next scene hangs. I am aware that this possibly could be fixed by looking at all that happens during the scene change, but is it a problem that others also experience or am I the only one ?

 

The other is a function to test and remove illegal characters in a textfield. In the text listener I have added the following code: 

function textListener( event )

  if ( event.phase == "began" ) then
    -- (...)
  elseif ( event.phase == "ended" or event.phase == "submitted" ) then
    -- (...)
  elseif ( event.phase == "editing" ) then
      --print( "new char: "..event.newCharacters )
      local newChar = event.newCharacters
      if newChar then
        local thePos =  string.find(theAllowedCharacters,newChar) or 0

        if thePos == 0 then

       --  print("Illegal char - replace with previous text")

          event.target.text = thePreviousText
          event.target:setSelection(event.startPosition-1,event.startPosition-1)

        else
        --  print("Legal char")
          thePreviousText = event.target.text
        end

      end

    end

This seems to work OK, but if I keep on hitting the keyboard keys quickly I end up with an error on the string.find function that says "unfinished capture" and the program crashes.

 

Is there a solution to allow Corona to execute the code before it continues the processing - or do you have a better way to test of acceptable input (in this case I do not want characters outside the normal letters and numbers (including national characters like æ ø å ä ö ü and î etc.....)

 

 




[topic_controls]
[/topic_controls]