Like I said, if you use gadgets, then use a hotkey. If you want the user to type the name into something else (like a canvas or opengl gadget), do it with ExamineKeyboard.
Since I only work with gadgets, someone else may be more helpful on the second one.
- Standard gadgets do not belong in the OpenWindowedScreen window area.
- A FlipBuffer always belongs in the loop
- In a loop all window events must always be queried in their own loop
Please also have a look at the example of PB WindowedScreen.
If you want to have gadgets for a game in the screen, have a look at the Window3D and Gadget3D library.
So far I only see that you want to query the keyboard. Unless you are talking about 2D/3D graphics output for a game, OpenWindowedScreen has no business here.
mk-soft wrote: Thu Nov 10, 2022 9:46 am
@Distored Pixel
I don't know what you want to achieve, but...
- Standard gadgets do not belong in the OpenWindowedScreen window area.
- A FlipBuffer always belongs in the loop
- In a loop all window events must always be queried in their own loop
Please also have a look at the example of PB WindowedScreen.
If you want to have gadgets for a game in the screen, have a look at the Window3D and Gadget3D library.
So far I only see that you want to query the keyboard. Unless you are talking about 2D/3D graphics output for a game, OpenWindowedScreen has no business here.
I have not included all the code where the input routine will above will go into. Everything in my current code works, but I don't have a user input routine implemented into it yet. That is what this is all about. I copied and pasted an example from the help files into a new code file to try to get an user input routine to work on it's own first and then implement it in.
Currently I have a window with an ImageGadget and 2 TextGadgets and a StringGadget. My first post is the example I am working on and I am trying to get it so the user can type his name in and hit the "ReturnKey" and it will save their name to a file. But first I was trying to get it work to debug properly and then work on the saving part.
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar?
No one cares how much you know until they know how much you care
; output PlayerName variable to debug
Global PlayerName.s
If OpenWindow(0, 0, 0, 322, 50, "StringGadget example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
InitSprite()
InitKeyboard()
If OpenWindowedScreen(WindowID(0), 0, 0, 322, 50)
StringGadget(1, 8, 10, 306, 20, "" + PlayerName)
Repeat
ExamineKeyboard()
PlayerName = GetGadgetText(1)
If KeyboardPushed(#PB_Key_Return) And return_key_down = #False
Debug PlayerName
return_key_down = #True
ElseIf KeyboardReleased(#PB_Key_Return) And return_key_down = #True
return_key_down = #False
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndIf
Thank you, yours looks like what I was trying to do, but some times my mind goes blank with what I should be doing in the code. Currently I'm not real good with If/ElseIf's and Select/EndSelect.
Yours works the same as the Select/EndSelect above. I'll study yours and the Select/EndSelect above and learn from them both and figure out which one is the best to use
To be popular is way to much work. I just want to be me, myself and I. Oh no, does that mean I'm bipolar?
No one cares how much you know until they know how much you care