The daily target in the habit editor is now a number field between the - and + buttons: it takes digits only, opens the number keyboard on Android, and allows targets up to 9999 instead of stopping at 99. Requested in Lumi feedback from Inner Breeze 2.1.31. Kryon d7454f8f adds the numeric text field mode, so the Android activity takes the numeric flag in setTextInputState; the lock moves to it (it also brings fbc07f54, held-key repeat). Co-Authored-By: Claude Opus 5.5 <[email protected]>
172 lines
5.4 KiB
Ziran
172 lines
5.4 KiB
Ziran
#import "android_device"
|
|
#import "android_text_editor"
|
|
#import, file "../src/platform/android/android_activity.zi";
|
|
#import "android_jni"
|
|
#import, file "../src/platform/raylib_text_input.zi";
|
|
#import, file "../src/app/host_services.zi";
|
|
#import "session"
|
|
#import "text_input_props"
|
|
#import "text_input_platform"
|
|
#import "tree"
|
|
#import "tree_input"
|
|
#import "text_host"
|
|
#import "text_request"
|
|
#import "widget_kind"
|
|
using WidgetKind;
|
|
|
|
EditorFrame :: (session: Session, key: u64, value: string) -> s32 {
|
|
TreeStart(session, 1, .{0.0, 0.0, 400.0, 600.0})
|
|
node := TreeSubmitCurrent(session, key, WidgetKindTextArea, .{10.0, 20.0, 300.0, 50.0})
|
|
TreeSetInteractive(session, node, false, false, 1)
|
|
TreeSetSelected(session, node, true)
|
|
TreeSetTextValue(session, node, value, cast(s32)value.count, cast(s32)value.count, false, false)
|
|
TextHostPresent(session, node, value, cast(s32)value.count, cast(s32)value.count, false, false, false, false)
|
|
if !TreeFinish(session) {
|
|
return -1
|
|
}
|
|
unused TreeFocusAt(session, node)
|
|
AndroidTextInputFrame(session, true)
|
|
return node
|
|
}
|
|
|
|
// No Java activity or display is used by this transport test.
|
|
#program_export
|
|
GetAndroidApp :: () -> *NativeAndroidApp {
|
|
return null
|
|
}
|
|
#program_export
|
|
GetCharPressed :: () -> s32 {
|
|
// Android must consume the Java queue, even if raylib saw the same key.
|
|
return 65
|
|
}
|
|
#program_export
|
|
IsKeyPressed :: (key: s32) -> bool {
|
|
unused key
|
|
return false
|
|
}
|
|
#program_export
|
|
IsKeyPressedRepeat :: (key: s32) -> bool {
|
|
unused key
|
|
return false
|
|
}
|
|
#program_export
|
|
IsKeyDown :: (key: s32) -> bool {
|
|
unused key
|
|
return false
|
|
}
|
|
#program_export
|
|
GetClipboardText :: () -> *u8 {
|
|
return null
|
|
}
|
|
#program_export
|
|
SetClipboardText :: (text: *u8) {
|
|
unused text
|
|
}
|
|
|
|
#program_export
|
|
main :: () -> s32 {
|
|
session := SessionOpen()
|
|
AndroidTextInputOpen(session)
|
|
// A callback before any field owns text focus must be ignored.
|
|
AndroidNativeTextCommit(null, null, 65)
|
|
AndroidTextInputBeginFrame(session)
|
|
if AndroidTextInputCharacter() != 0 {
|
|
return 1
|
|
}
|
|
AndroidTextInputFrame(session, true)
|
|
AndroidNativeTextCommit(null, null, 233)
|
|
AndroidNativeTextCommit(null, null, 128512)
|
|
AndroidNativeTextCommit(null, null, 55296)
|
|
AndroidNativeTextBackspace(null, null)
|
|
AndroidNativeTextBackspace(null, null)
|
|
AndroidNativeTextEnter(null, null)
|
|
AndroidNativeTextCommit(null, null, 90)
|
|
typed: [32]u8
|
|
AndroidTextInputBeginFrame(session)
|
|
first := SampleTextFieldInput(true, typed[:])
|
|
if first.text != "é😀" || first.backspace || first.commit {
|
|
return 2
|
|
}
|
|
AndroidTextInputBeginFrame(session)
|
|
second := SampleTextFieldInput(true, typed[:])
|
|
if second.text.count != 0 || !second.backspace || second.commit {
|
|
return 3
|
|
}
|
|
AndroidTextInputBeginFrame(session)
|
|
third := SampleTextFieldInput(true, typed[:])
|
|
if third.text.count != 0 || !third.backspace || third.commit {
|
|
return 4
|
|
}
|
|
AndroidTextInputBeginFrame(session)
|
|
fourth := SampleTextAreaInput(true, typed[:])
|
|
if fourth.text.count != 0 || fourth.backspace || !fourth.enter || fourth.commit {
|
|
return 5
|
|
}
|
|
AndroidTextInputBeginFrame(session)
|
|
fifth := SampleTextFieldInput(true, typed[:])
|
|
if fifth.text != "Z" || fifth.backspace || fifth.commit {
|
|
return 6
|
|
}
|
|
AndroidNativeTextCommit(null, null, 66)
|
|
AndroidTextInputFrame(session, false)
|
|
AndroidTextInputBeginFrame(session)
|
|
if AndroidTextInputCharacter() != 0 {
|
|
return 7
|
|
}
|
|
AndroidTextInputClose(session)
|
|
SessionClose(session)
|
|
replacement := SessionOpen()
|
|
if replacement.slot != session.slot || replacement.epoch == session.epoch {
|
|
return 8
|
|
}
|
|
AndroidNativeTextCommit(null, null, 67)
|
|
AndroidTextInputOpen(replacement)
|
|
AndroidTextInputFrame(replacement, true)
|
|
AndroidTextInputBeginFrame(replacement)
|
|
if AndroidTextInputCharacter() != 0 {
|
|
return 9
|
|
}
|
|
AndroidTextInputClose(session)
|
|
AndroidNativeTextCommit(null, null, 68)
|
|
AndroidTextInputBeginFrame(replacement)
|
|
if AndroidTextInputCharacter() != 68 {
|
|
return 10
|
|
}
|
|
AndroidTextInputClose(replacement)
|
|
SessionClose(replacement)
|
|
editor := SessionOpen()
|
|
AndroidTextInputOpen(editor)
|
|
node := EditorFrame(editor, 100, "")
|
|
if node < 0 || !AndroidTextEditorUpdate(6, 1, "hel", 3, 3) {
|
|
return 11
|
|
}
|
|
if !AndroidTextEditorUpdate(6, 2, "hello 水😀", 13, 13) ||
|
|
AndroidTextEditorUpdate(6, 1, "old", 3, 3) {
|
|
return 12
|
|
}
|
|
AndroidTextInputBeginFrame(editor)
|
|
request := TextRequestTake(editor, node)
|
|
if !request.pending || !request.replace || request.value != "hello 水😀" || request.cursor != 13 {
|
|
return 13
|
|
}
|
|
// Replacing a focused field changes its identity. Late IME callbacks from
|
|
// the preceding editor must never overwrite the new field.
|
|
node = EditorFrame(editor, 101, "saved draft")
|
|
if AndroidTextEditorUpdate(6, 3, "late", 4, 4) ||
|
|
!AndroidTextEditorUpdate(7, 1, "new", 3, 3) {
|
|
return 14
|
|
}
|
|
AndroidTextInputBeginFrame(editor)
|
|
request = TextRequestTake(editor, node)
|
|
if !request.pending || request.value != "new" {
|
|
return 15
|
|
}
|
|
AndroidTextInputFrame(editor, false)
|
|
if AndroidTextEditorUpdate(7, 2, "after blur", 10, 10) {
|
|
return 16
|
|
}
|
|
AndroidTextInputClose(editor)
|
|
SessionClose(editor)
|
|
return 0
|
|
}
|