Поддерживать фокус с двумя текстовыми полями и кнопкой, используя Brightscript - PullRequest
1 голос
/ 10 июля 2019

Я создал одну форму входа в светлый сценарий.Он следует

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '«» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «»«» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «»'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '*

TextBox 1 'Здесь активен фокус. Я установил по умолчанию в поле TextBox active = true

TextBox 2 ' Здесь нажмите клавишу вниз, чтобы активировать true

Кнопка 1 'Здесь снова нажмите клавишу вниз, чтобы сфокусировать значение true

' '' '' '' '' '' '' '' '' '' '' '' ''«» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «»«» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «»«» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «» «»'' '' '' '' ''

Здесь я поддерживаю 3 предмета, используя 3 разных ключа.Теперь я хочу сохранить одну клавишу для всех 3 пунктов, используя клавишу «вниз».Любая идея, как сохранить Focus с помощью Brightscript.

Я использовал одну функцию для обработки ключей. Здесь

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

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

end function

Теперь я сохранил ключ, как будто я установил TextBox Focus активным в ByDefault, чтобыФайл XML. Теперь я применяю логику ниже.Фокус первого элемента установлен на 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.Я использовал то же самое в клавише «Вверх».

Здесь я использую «и», тогда возникнет проблема, есть ли какая-либо идея.

Пожалуйста, проверьте Вот изображение действительно то, что я хочу сделать,enter image description here

Отредактированное сообщение:

Я работаю с клавишами вверх и вниз с кодом ниже.Это работает, но, это работает только один раз.

 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   

Спасибо.

1 Ответ

0 голосов
/ 11 июля 2019

Отметьте здесь .

Вы должны использовать .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
...