簡體   English   中英

使用Brightscript通過兩個文本框和按鈕保持焦點

[英]Maintain Focus with two textbox and button using Brightscript

我在明亮的腳本中創建了一個“登錄表單”。 在下面

'''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''

TextBox 1 '焦點處於活動狀態,我默認在TextBox字段中設置active = true

TextBox 2 '在這里按下鍵激活true

按鈕1 '再按一次此鍵即可

'''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''

在這里,我使用3個不同的鍵維護3個項目。 現在,我想使用向下鍵為所有3個項目維護單個鍵。 任何人如何使用Brightscript維護Focus的想法。

我使用了一個函數進行鍵處理

function onKeyEvent(key as String, press as Boolean) as Boolean

.................

end function

現在,我像保持默認狀態下將TextBox Focus設置為XML File一樣保持鍵,現在將Logic應用於下面。 默認情況下,第一項重點放在XML文件上。

if key = "down" then 
       'Here Second item focus
       m.keypass.active = true ' Here work successfully First time
       if key = "down" and m.keypass.active = true and m.btnsub.active = false then
          'Here not maintain successfully its directly call here I press the down key.       
           m.keypass.active = false    
           m.btnsub.active = true 'Here third item focus is not maintained 

       end if
end if

我第一次按下向下鍵,它工作正常,但是第二次如何處理Focus。 我在向上鍵中使用了同樣的方法。

在這里我使用“ and”,那么如果有任何想法,問題就會發生。

請檢查這是我真正想做的圖像。 在此處輸入圖片說明

編輯后:

我使用以下代碼使用向上和向下鍵進行處理。 它正在工作但是,它只能一次運行。

 if key = "up" or key = "down"  
        if key = "down" 

          ?"here down key"

            if m.keypass.id = "instructpass" and m.keypass.active = true
                  ? "down key if part"
                  m.btngrp.setFocus(true)
                  m.keypass.active = false         
                  handled = true
            else if m.keyid.id = "instructid" and m.keyid.active = true 
                ?" down key else part"     
                m.keypass.active = true
                m.keyid.active = false
                handled = true
            else if m.btngrp.buttonSelected = 0
                m.keyid.active = true
                m.btngrp.setFocus(false)
                handled = true              
            end if 

            handled = true

       else if key = "up" 

         ? "here up key"

           if  m.keypass.active = true
                  ?"up key if part"
                  m.keyid.active = true
                  m.keypass.active = false
                  handled = true
           else if  m.keyid.active = true
                  ?"id key"
                  m.btngrp.setFocus(true)
                  m.btngrp.focusButton = 1
                  m.keyid.active = false        
                  handled = true

           else if m.btngrp.focusButton = 0 and m.btngrp.buttonSelected = 0
                ?"up key else part"
                m.keypass.active = true
                m.keypass.setFocus(true)     
                m.btngrp.setFocus(false)
                handled = true

            end if

                handled = true
        end if
        handled = true
end if   

謝謝。

在這里檢查。

您應該使用.setFocus(true)和.hasFocus(),它們可用於大多數可渲染節點,例如TextEditBox和Button。

例如

if key = "down" then 
    if textBox1.hasFocus() then 
        textBox2.setFocus(true)
    elseif textBox2.hasFocus() then 
        button.setFocus(true)
    end if
end if

if key = "up" then 
    if button.hasFocus() then 
        textBox2.setFocus(true)
    elseif textBox2.hasFocus() then 
        textBox1.setFocus(true)
    end if
end if

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM