Hi, how do I enable a form to capture the carriage return when pressed.
So I have form with username and password for login purposes.
When the user presses carriage return, I want it to be like the 'login' button which I capture and process.
I looked at all the form events, and I didn't find it.
Can someone please advice.
Window event carriage return
Re: Window event carriage return
One approach:lesserpanda wrote:...When the user presses carriage return, I want it to be like the 'login' button which I capture and process...
Code: Select all
Procedure doLogin()
MessageRequester("Login", "Login button clicked!")
; login processes here...
EndProcedure
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 300, 130, "Keyboard Shortcuts", wFlags)
StringGadget (1, 10, 10, 280, 30, "Name")
StringGadget (2, 10, 50, 280, 30, "Password")
ButtonGadget (3, 10, 90, 280, 30, "LOGIN")
SetActiveGadget(1)
AddKeyboardShortcut(0, #PB_Shortcut_Return, 1)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case 3 ;login button
doLogin()
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 1 ;return key
Select GetActiveGadget()
Case 1 ;name box
SetActiveGadget(2)
Case 2 ;password box
doLogin()
EndSelect
EndSelect
EndSelect
Until appQuit
EndIf
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
-
- User
- Posts: 65
- Joined: Tue Feb 11, 2020 7:50 am
Re: Window event carriage return
Hi thanks for the quick reply and great code. Much appreciated.
It's all good now and can capture the chr(13) but how do I get the values of those StringGadgets? Sorry for the newbie question. First day on PB.
I was trying ..
But it says specified #Gadget is not intialized
It's all good now and can capture the chr(13) but how do I get the values of those StringGadgets? Sorry for the newbie question. First day on PB.
I was trying ..
Code: Select all
If OpenWindow(0, x, y, width, height, "Login", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_WindowCentered)
strEmail = StringGadget(1, 430, 130, 220, 25, "", #PB_String_LowerCase)
TextGadget(#PB_Any, 350, 130, 70, 25, "Email:")
ButtonGadget(#PB_Any, 520, 210, 130, 45, "Login")
TextGadget(#PB_Any, 350, 170, 70, 25, "Password")
strPassword = StringGadget(2, 430, 170, 220, 25, "", #PB_String_Password)
AddKeyboardShortcut(0, #PB_Shortcut_Return, 1)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case 3 ;login button
email.s = GetGadgetText(strEmail)
password.s = GetGadgetText(strPassword)
doLogin(email, password)
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 1 ;return key
Select GetActiveGadget()
Case 1 ;name box
SetActiveGadget(2)
Case 2 ;password box
email.s = GetGadgetText(strEmail)
password.s = GetGadgetText(strPassword)
doLogin(email, password)
EndSelect
EndSelect
EndSelect
Until appQuit
EndIf
Re: Window event carriage return
Simply like this:lesserpanda wrote:...how do I get the values of those StringGadgets?
Code: Select all
Procedure doLogin()
msgText$ = "Name: " + GetGadgetText(1) + #CRLF$ +
"Password: " + GetGadgetText(2)
MessageRequester("Login", msgText$)
EndProcedure
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 300, 130, "Keyboard Shortcuts", wFlags)
StringGadget (1, 10, 10, 280, 30, "Name")
StringGadget (2, 10, 50, 280, 30, "Password")
ButtonGadget (3, 10, 90, 280, 30, "LOGIN")
SetActiveGadget(1)
AddKeyboardShortcut(0, #PB_Shortcut_Return, 1)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Gadget
Select EventGadget()
Case 3 ;login button
doLogin()
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 1 ;return key
Select GetActiveGadget()
Case 1 ;name box
SetActiveGadget(2)
Case 2 ;password box
doLogin()
EndSelect
EndSelect
EndSelect
Until appQuit
EndIf
Code: Select all
result = StringGadget(2, 430, 170, 220, 25, "", #PB_String_Password)
Code: Select all
strPassword = StringGadget(#PB_Any, 430, 170, 220, 25, "", #PB_String_Password)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
-
- User
- Posts: 65
- Joined: Tue Feb 11, 2020 7:50 am
Re: Window event carriage return
Got it.. Thank you very much!