を集中失いますテキストフィールドをisSecure = trueに変更して、*記号を付けます。 私のアプローチ私は最初の手紙の後に私のテキストフィールドがフォーカスを失うという問題があります。ここコロナSDK - native.newTextField - 私はnative.newTextFieldが</p> <p>を「パスワードを入力」にする場合はfalseとプレースホルダにのisSecureオプションを設定して、いつでもユーザー開始タイピング作成するときに私が達成したいことはある
が私のコードです:
local function fieldHandler(event)
if ("began" == event.phase) then
-- This is the "keyboard has appeared" event
-- In some cases you may want to adjust the interface when the keyboard appears.
elseif ("ended" == event.phase) then
-- This event is called when the user stops editing a field: for example, when they touch a different field
if(event.target.id == "password" and event.target.text == "")then
event.target.isSecure = false
passwordField.placeholder = "type your password"
end
elseif ("editing" == event.phase) then
if(event.target.id == "password" and string.len(event.target.text) >0) then
event.target.isSecure = true
--native.setKeyboardFocus(event.target)
end
elseif ("submitted" == event.phase) then
-- Hide keyboard
native.setKeyboardFocus(nil)
end
エンド
--scene: --Did
local passwordField = native.newTextField(_CX - fieldWidth/2, passwordFieldBg.y, fieldWidth, 40)
passwordField.id = "password"
passwordField:addEventListener("userInput", fieldHandler)
group:insert(passwordField)
passwordField.hasBackground = false
passwordField.anchorX = 0
passwordField.placeholder = "type your password"
passwordField.autocorrectionType = "UITextAutocorrectionTypeNo"
passwordField.isSecure = false
passwordField.font = native.newFont(gM.fontDin)
passwordField:resizeFontToFitHeight()
を示し、私はこの問題を解決するのに役立つ、またはその私ができる別のアプローチください。つかいます。
おかげで、
バージョン2016.2883(2016年5月17日)
されている理由あなたは値を変更していますか?常に真実に保ち、 'プレースホルダー 'に干渉しません。 –
それは私がやっているやり方を少なくとも妨害します。 最初にプレースホルダを呼び出してからisSecureを実行すると、プレースホルダのテキストが消えます。前 :--Hereプレースホルダーテキストは、彼の値を保持します:--Hereプレースホルダーテキストをリセットした後、 " \t \t passwordField.placeholder = " \t \t" あなたのパスワードを入力しpasswordField.isSecure =真 " へ。 \t \t passwordField.isSecure =真 \t \t passwordField.placeholder =私はそれを考え出す助けるため おかげで "パスワードを入力"。 –