Add input logging
This commit is contained in:
@@ -120,7 +120,9 @@ func (p *LicenseKeyPage) Init(app ApplicationInterface) error {
|
||||
p.isFirstTimeSetup = true
|
||||
}
|
||||
|
||||
logger.Info("[LicenseKeyPage.Init] Calling sdl.StartTextInput(), isFirstTimeSetup=%v", p.isFirstTimeSetup)
|
||||
sdl.StartTextInput()
|
||||
logger.Info("[LicenseKeyPage.Init] After StartTextInput: IsTextInputActive=%v", sdl.IsTextInputActive())
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -156,21 +158,36 @@ func formatLicenseKey(input string) string {
|
||||
// HandleEvent processes SDL events and handles them appropriately for the LicenseKeyPage.
|
||||
func (p *LicenseKeyPage) HandleEvent(event *sdl.Event) error {
|
||||
actualEvent := *event
|
||||
if !sdl.IsTextInputActive() {
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] Event type: %T", actualEvent)
|
||||
|
||||
isActive := sdl.IsTextInputActive()
|
||||
if !isActive {
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] TextInput not active, calling StartTextInput()")
|
||||
sdl.StartTextInput()
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] After StartTextInput: IsTextInputActive=%v", sdl.IsTextInputActive())
|
||||
}
|
||||
|
||||
switch e := actualEvent.(type) {
|
||||
case *sdl.TextInputEvent:
|
||||
text := e.GetText()
|
||||
// Add the new character and reformat
|
||||
p.inputText += e.GetText()
|
||||
p.inputText += text
|
||||
p.inputText = formatLicenseKey(p.inputText)
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] TextInputEvent: received=%q, inputText=%q", text, p.inputText)
|
||||
// Clear error when user starts typing
|
||||
p.errorMessage = ""
|
||||
case *sdl.KeyboardEvent:
|
||||
eventType := "KEYDOWN"
|
||||
if e.Type == sdl.KEYUP {
|
||||
eventType = "KEYUP"
|
||||
}
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] KeyboardEvent: type=%s, sym=%d (%s), scancode=%d, mod=0x%04x",
|
||||
eventType, e.Keysym.Sym, sdl.GetKeyName(e.Keysym.Sym), e.Keysym.Scancode, e.Keysym.Mod)
|
||||
|
||||
if e.Type == sdl.KEYDOWN {
|
||||
switch e.Keysym.Sym {
|
||||
case sdl.K_ESCAPE:
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] ESCAPE pressed, isFirstTimeSetup=%v", p.isFirstTimeSetup)
|
||||
// Block escape during first-time setup
|
||||
if p.isFirstTimeSetup {
|
||||
return nil
|
||||
@@ -179,6 +196,7 @@ func (p *LicenseKeyPage) HandleEvent(event *sdl.Event) error {
|
||||
sdl.StopTextInput()
|
||||
p.App.UnwindToPage(&Settings{})
|
||||
case sdl.K_RETURN:
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] RETURN pressed, inputText=%q", p.inputText)
|
||||
// Validate license key - check empty first, then length, then characters
|
||||
cleaned := strings.ReplaceAll(p.inputText, "-", "")
|
||||
if cleaned == "" {
|
||||
@@ -228,6 +246,7 @@ func (p *LicenseKeyPage) HandleEvent(event *sdl.Event) error {
|
||||
cleaned = cleaned[:len(cleaned)-1]
|
||||
}
|
||||
p.inputText = formatLicenseKey(cleaned)
|
||||
logger.Info("[LicenseKeyPage.HandleEvent] BACKSPACE: inputText=%q", p.inputText)
|
||||
// Clear error when user edits input
|
||||
p.errorMessage = ""
|
||||
}
|
||||
@@ -453,6 +472,7 @@ func (p *LicenseKeyPage) Destroy() error {
|
||||
p.errorTextureID = 0
|
||||
}
|
||||
|
||||
logger.Info("[LicenseKeyPage.Destroy] Calling sdl.StopTextInput()")
|
||||
sdl.StopTextInput()
|
||||
return p.Base.Destroy()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user