Files
kryon/examples/13_text_editor.kry
T
2026-08-23 22:47:03 -03:00

31 lines
1.1 KiB
Plaintext

#import "kryon.h"
app "Kryon Text Editor" {
size 800 600
fps 60
font examples
}
state {
text_value: [512] char = "Edit this text."
cursor: int = 15
focused: int = 0
scroll: int = 0
}
TextEditorExample :: (viewport: Rectangle) #ui {
Screen root: {
bounds = viewport
Background(GetThemeBackground())
TextArea((TextAreaProps){{40,70,520,180},text_value,sizeof(text_value),&cursor,&focused,&scroll,500,Text16,6,401,"Write here",SyntaxNone,{0},NULL,NULL})
Text("Ctrl/Cmd+C,X,and V work in the text area.", 40, 260, Text16, GetThemeText())
if Button((ButtonProps){.bounds = {40, 300, 110, 34}, .label = "Copy", .style = ButtonStyleSecondary, .font = Text16, .id = 101}) {
SetUIClipboardTextValue(text_value)
}
if Button((ButtonProps){.bounds = {170, 300, 110, 34}, .label = "Paste", .style = ButtonStyleSecondary, .font = Text16, .id = 102}) {
clip: const char * = GetUIClipboardTextValue()
snprintf(text_value,sizeof(text_value),"%s",clip)
}
}
}