Page 1 of 1
[SOLVED] Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 12:19 am
by Randy Walker
My old nemisis has returned and i can't figure it out. I need to know when Enter key is pressed inside an editorgadget without breaking the normal behavior. This will catch the enter key but does not move cursor to next line at the same time:
Code: Select all
If OpenWindow(1, 100,100,310,510, "My_QUICK_NOTE w/autosave", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_TitleBar)
EditorGadget(1, 5, 5, 270, 500) : AddKeyboardShortcut(1,#PB_Shortcut_Return,2)
Repeat
_mess=WaitWindowEvent()
If _mess=#PB_Event_Menu
which=EventMenu()
If which=2
Debug "Enter was pressed"
EndIf
EndIf
Until _mess=#PB_Event_CloseWindow
EndIf
I'm hoping for solution that does not require a callback. I hate callbacks.
Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 12:37 am
by RASHAD
Hi Randy
Code: Select all
If OpenWindow(1, 100,100,310,510, "My_QUICK_NOTE w/autosave", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_TitleBar)
EditorGadget(1, 5, 5, 270, 500)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_CHAR
key = EventwParam()
If key = 13
Debug "Return key pressed"
EndIf
EndSelect
Until Quit = 1
EndIf
Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 12:43 am
by Randy Walker
RASHAD wrote: Tue Mar 04, 2025 12:37 am
Hi Randy
Code: Select all
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_CHAR
key = EventwParam()
If key = 13
Debug "Return key pressed"
EndIf
EndSelect
Wow!!1 Thanks RASHAD!!!! So PERFECT. Never would hve guessed to try WM_CHAR
You saved my life again.
THANKS!!!!
Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 1:37 am
by Randy Walker
UHHg ???? Appears there was a reply here from ChrisR according to Notifications but it mysteriously vanished.
Thanks anyway ChrisR

Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 10:46 am
by ChrisR
yes, I hadn't refreshed, didn't see that Rahab had given the right answer

Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 1:13 pm
by blueb
I love the smell of
Rahab in the morning!

Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 3:00 pm
by ChrisR
Oops, sorry my friend Rashad, I guess it's my phone's automatic correction

Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 8:39 pm
by Randy Walker
blueb wrote: Tue Mar 04, 2025 1:13 pm
I love the smell of
Rahab in the morning!

Re: Catch Enter key without breaking it?
Posted: Tue Mar 04, 2025 8:47 pm
by Randy Walker
ChrisR wrote: Tue Mar 04, 2025 3:00 pm
I guess it's my phone's automatic correction
I hate that so much. People that created and enabled that should be hung on he street corner for inflicting mass embarrassment. It's just not right.
