使用Brightscript通过两个文本框和按钮保持焦点 [英] Maintain Focus with two textbox and button using Brightscript
问题描述
我在明亮的脚本中创建了一个登录表单".正在关注
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''>
TextBox 1 '这里的焦点是活动的,我默认在TextBox字段中设置active = true
文本框2 '在这里按下键激活true
按钮1 '再次按下此键可将焦点对准真
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''>
在这里,我使用3个不同的键维护3个项目.现在,我想使用向下键为所有3个项目维护单个键.任何人都想知道如何使用Brightscript保持焦点.
我使用了一个函数来进行键处理
函数onKeyEvent(键为String,按Boolean)为Boolean........终端功能
现在,我保持了像我在默认情况下将TextBox Focus设置为XML File,现在将Logic应用于下面.默认情况下,第一项重点放在XML文件上.
如果key ="down"则'这里第二项重点m.keypass.active = true'在这里成功工作第一次如果key ="down"并且m.keypass.active = true和m.btnsub.active = false,则这里没有成功保持直接呼叫,我按下向下键.m.keypass.active =假m.btnsub.active = true'此处未保持第三项焦点万一万一
我第一次按下向下键,效果很好,但是第二次如何处理Focus.我在向上键中使用了相同的内容.
在这里我使用"and",那么如果有任何想法,问题就会发生.
请检查一下这是我真正想做的图像.
编辑后的帖子:
我用下面的代码使用向上和向下键进行处理.它正在工作,但是,它一次只能工作.
如果key ="up"或key ="down"如果键=向下"?这里按下键"如果m.keypass.id ="instructpass"和m.keypass.active = true?按下键,如果有的话"m.btngrp.setFocus(true)m.keypass.active =假处理=真否则,如果m.keyid.id ="instructid"并且m.keyid.active = true?向下键其他部分"m.keypass.active = truem.keyid.active = false处理=真否则,如果m.btngrp.buttonSelected = 0m.keyid.active = truem.btngrp.setFocus(false)处理=真万一处理=真否则,如果key ="up"?这里键"如果m.keypass.active = true?向上键(如果有)"m.keyid.active = truem.keypass.active =假处理=真否则,如果m.keyid.active = true?"ID键"m.btngrp.setFocus(true)m.btngrp.focusButton = 1m.keyid.active = false处理=真否则,如果m.btngrp.focusButton = 0和m.btngrp.buttonSelected = 0?上调键其他部分"m.keypass.active = truem.keypass.setFocus(true)m.btngrp.setFocus(false)处理=真万一处理=真万一处理=真万一
谢谢.
检查此处.
您应该使用.setFocus(true)和.hasFocus(),它们可用于大多数可渲染节点,例如TextEditBox和Button.
例如
如果key ="down"则如果textBox1.hasFocus()然后textBox2.setFocus(true)elseif textBox2.hasFocus()然后button.setFocus(true)万一万一如果key ="up",则如果button.hasFocus()然后textBox2.setFocus(true)elseif textBox2.hasFocus()然后textBox1.setFocus(true)万一万一
I created a one Login Form in the bright script. It's following
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TextBox 1 ' Here the focus is active I set by default in TextBox field active = true
TextBox 2 ' Here the press down key to active true
Button 1 ' Here again press down key to focus true
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Here, I maintain the 3 Items using 3 different key. Now I want to maintain the single key for all 3 items using the down key. Anyone idea to How to maintain Focus using Brightscript.
I used the one function for key handling It's here
function onKeyEvent(key as String, press as Boolean) as Boolean
.................
end function
Now, I maintained the key like I set TextBox Focus active in ByDefault to XML File.Now I apply Logic to below. First item focus set on XML file by default.
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
I first-time press the down key It's working fine But its second time How handling the Focus. I used the same thing in Up key.
Here I am using "and" then the issue will happen is there any idea.
Pls, Check Here's an image really what I want to do.
Edited Post:
I handle with up and down key with below code. It's working But, Its only work in a single time.
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
Thank you.
Check here.
You should use .setFocus(true) and .hasFocus(), which are available to most renderable nodes such as TextEditBox and Button.
E.g.
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
这篇关于使用Brightscript通过两个文本框和按钮保持焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!