Set focus

you should be able to do a Lianja.GetElementById(“page1.section1.field61”).se tfocus in the Ready Delegate of your section. That will set the initial focus to field61.
Then you should be able to do the same where ever else you want to
shift the focus. Obviously it doesn’t make much sense to change focus in an Interactive Change Delegate (which fires on every key press) unless you only expect a single character to be entered.


Q:
when I open the app, and switch between section1 and section2. If I switch pages focus is not restored.Now if I add a second page (page2), and switch to it and come back to page1, this same code runs but the focus is not set.
A:
The Lianja.get(“page.section”).textbox.setfocus() needs to be in the page.activate() so that it is called when you switch pages.


I’ve got three pages in my App: tsearch, page2 and page3. On tsearch I have 2 Canvas Sections, section1 and section2 and they are in a TabView Section, section3. Section1 and Section2 each have 2 textboxes (section1 has field61 and field12, section2 has field1 and field2). InteractiveChange is set up on field61 and field1 as per your earlier code, they also have a change delegate set up to update a variable then switch to one of the other pages. When you reselect the tsearch page, the variable is used to take you back to the original textbox.

Code:
////////////////////////////////////////////////////////////////
// Event delegate for 'activate' event
proc tsearch_activate()
        if m_wherecalled = "section1"
            Lianja.showdocument("section:section3?action=select&text=section1")
            Lianja.get("tsearch.section1").field61.setfocus()
        else
            Lianja.showdocument("section:section3?action=select&text=section2")
            Lianja.get("tsearch.section2").field1.setfocus()
        endif
        
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'ready' event
proc tsearch_ready()
    Lianja.showdocument("section:section3?action=select&text=section1")
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'init' event
proc tsearch_init()
    public m_wherecalled = "section1"
    public vsearch, vsearch2
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'changed' event
proc tsearch_section2_field1_changed()
    m_wherecalled = "section2"
    Lianja.showdocument("page:page3")
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'interactivechange' event
proc tsearch_section1_field61_interactivechange()
    vsearch = this.text
    Lianja.get("tsearch.section1").field12.text = vsearch
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'ready' event
proc tsearch_section1_ready()
    lianja.get("tsearch.section1").field61.text = " "
    vsearch = " "
    Lianja.get("tsearch.section1").field12.text = vsearch
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'changed' event
proc tsearch_section1_field61_changed()
    m_wherecalled = "section1"
    Lianja.showdocument("page:page2")
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'interactivechange' event
proc tsearch_section2_field1_interactivechange()
    vsearch2 = this.text
    Lianja.get("tsearch.section2").field2.text = vsearch2
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'ready' event
proc tsearch_section2_ready()
    lianja.get("tsearch.section2").field1.text = " "
    vsearch2 = " "
    Lianja.get("tsearch.section2").field2.text = vsearch2
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'activate' event
proc tsearch_section1_activate()
    if Lianja.get("tsearch.section3").activepage = "section1"
        Lianja.get("tsearch.section1").field61.setfocus()
    endif
endproc


////////////////////////////////////////////////////////////////
// Event delegate for 'activate' event
proc tsearch_section2_activate()
    if Lianja.get("tsearch.section3").activepage = "section2"
        Lianja.get("tsearch.section2").field1.setfocus()
    endif
endproc