Results 1 to 1 of 1

Thread: [Answers] Set focus

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] 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





    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-20 at 03:45.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us