Page 1 of 1
Mimic command line behaviour in an EditorGadget()
Posted: Mon Jan 22, 2024 8:17 pm
by danny88
Hello
My first probleme was to find how to close a Console window without terminating the whole program. As I found out that it was impossible, is there a way to mimic a console behaviour inside an EditorGagdet, which means that the user can only enter input at the last cursor position and an output is generated when user hits "Enter" .
any other solution is welcome
Thanks
Re: Mimic command line behaviour in an EditorGadget()
Posted: Thu Sep 12, 2024 10:14 pm
by Randy Walker
Try this in v6.11 or above, Windows Only!!. (don't know about others) I don't think you can type anywhere except end of the text.
Code: Select all
#KB_Return = #PB_Shortcut_Return + 49152
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(0, a, "Line "+Str(a))
Next
AddKeyboardShortcut(0, #PB_Shortcut_Return, #KB_Return)
SetActiveGadget(0) ; necessary to get cursor active in edit box.
Repeat
SendMessage_(GadgetID(0),#EM_SETSEL,-1,-1) ; Force cursor to End of text.
Select EventMenu()
Case #KB_Return ; Catch Return Key
s$ = GetGadgetText(0) ;get input if return key
Break ; exit the loop with all text in s$
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Debug s$
[HINT] do web search for "EM_SETSEL" to learn about cursor placement and text selections.
Re: Mimic command line behaviour in an EditorGadget()
Posted: Fri Sep 13, 2024 1:20 pm
by Axolotl
Did you ask a similar question back in February?
Simulate Terminal in an EditorGadget
Does the RASHAD example not work?
Perhaps this is something for you?
Module: TerminalGadget
Re: Mimic command line behaviour in an EditorGadget()
Posted: Fri Sep 13, 2024 5:41 pm
by Randy Walker
Axolotl wrote: Fri Sep 13, 2024 1:20 pm
Did you ask a similar question back in February?
I didn't ask the question. I ran into this coding question post and noticed it had no reply so I replied.
Re: Mimic command line behaviour in an EditorGadget()
Posted: Fri Sep 13, 2024 11:04 pm
by Quin
Randy Walker wrote: Fri Sep 13, 2024 5:41 pm
Axolotl wrote: Fri Sep 13, 2024 1:20 pm
Did you ask a similar question back in February?
I didn't ask the question. I ran into this coding question post and noticed it had no reply so I replied.
Looks like the OP made two topics about this issue, this one that never got any replies until recently, and the one linked a couple posts back.
Re: Mimic command line behaviour in an EditorGadget()
Posted: Sun Sep 15, 2024 1:30 pm
by Axolotl
Yeah, Quin is right.
Quin wrote: Fri Sep 13, 2024 11:04 pm
Randy Walker wrote: ↑13 Sep 2024, 18:41
Axolotl wrote: ↑13 Sep 2024, 14:20
Did you ask a similar question back in February?
I didn't ask the question. I ran into this coding question post and noticed it had no reply so I replied.
Looks like the OP made two topics about this issue, this one that never got any replies until recently, and the one linked a couple posts back.
I (never) look at the date. So, Randy, if you felt offended. Here's my apology. Because that was not my intention.

Re: Mimic command line behaviour in an EditorGadget()
Posted: Sun Sep 15, 2024 9:51 pm
by Randy Walker
Axolotl wrote: Sun Sep 15, 2024 1:30 pm
Yeah, Quin is right.
I (never) look at the date. So, Randy, if you felt offended. Here's my apology. Because that was not my intention.

Nope, not offended. All comments welcome
