Android Question Problem: Rare behavior of RichString, cursor loose when use backcolor.

Discussion in 'Android Questions' started by ELCHARO, May 28, 2015.

  1. ELCHARO

    ELCHARO Member Licensed User

    Guys, when run this code in Phone and Emulator. Android 4+ the cursor disappear when use backcolor. If a general problem or make some mistake.
    Thanks again.

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        str.Initialize(str)
        
    Activity.AddView(str,0,0,200,200)
    End Sub

    Sub Activity_Resume
        str.Text=
    "Texto========11111111111111Texto"
        a=MakeColor(str.Text)
        str.Text=a
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub


    Sub MakeColor(sourcetxt As StringAs RichString
        
    Dim backcolor,frontcolor,numcolor,colorlevel As Int                'Take current color string
        Dim wordpos As Long
        
    Dim inpstr As String               
        inpstr=sourcetxt
      
        richstr.Initialize(inpstr)
    '==============================================================  
        backcolor=Colors.black     ' PROBLEM, WHEN USE BACKCOLOR
    '==============================================================
        numcolor=Colors.white
        frontcolor=
    Colors.White
        colorlevel=
    Colors.white
      
        
    For wordpos=0 To inpstr.Length-1   ' navigate de string.
            Select inpstr.CharAt(wordpos)   ' analize this char. 
                Case "+","=","/","*",".",":"," ","-","#","%","<",">","&"
                        onelinecolor(
    Colors.Blue,backcolor, wordpos, wordpos+1)
                
    Case Chr(10),Chr(32),Chr(9),Chr(13),Chr(15),Chr(44),Chr(34) ,Chr(39'SPACE TAB,LF,CR,COMA
                        richstr.backcolor(backcolor, wordpos, wordpos+2)  
                
    Case "1","2","3","4","5","6","7","8","9","0" 
                        onelinecolor(numcolor,backcolor, wordpos, wordpos+
    1)
                
    Case Else
                        richstr.Color(
    Colors.White,wordpos,wordpos+1 )   'CURSOR WORK HERE BECAUSE DON'T USE BACKCOLOR

            
    End Select
        
    Next
        
    Return richstr  

    End Sub

    Sub onelinecolor (col As Int,bcol As Int,pos As Int,size As Int)
        richstr.Color(col,pos,size )   
    ' color funciones
        richstr.backColor(bcol,pos,size )   ' color funciones
    End Sub


    ANY SUGESTIONS, WHY?

    Thanks Ricardo.
     
  2. DonManfred

    DonManfred Expert Licensed User

    maybe because there is a method with the same name.
    Code:
    richstr.backcolor(backcolor, wordpos, wordpos+2)
    Try to give the local variable(s) another name. for ex.
    Code:
    Dim bgcolor
    [..]
    richstr.backcolor(bgcolor, wordpos, wordpos+
    2)
     
    ELCHARO and mangojack like this.
  3. ELCHARO

    ELCHARO Member Licensed User

    Correct answer, thanks DonManfred.

    The problem is resolve.
    I need to check how i write the declarations ,because i believe B4X resolve this things. But not.
     
    Last edited: May 28, 2015
    DonManfred likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice