Page 1 of 2
Retrieve text from StringGadget that is inside ContainerGadget
Posted: Tue Jul 02, 2024 5:50 pm
by Distorted Pixel
Hi,
If I run the code of the one window that has the StringGadget inside the ContainerGadget it debugs the user typed text fine, but if I run the same window with the rest of my program it will not debug at all. Why would this happen?
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Tue Jul 02, 2024 6:22 pm
by boddhi
Distorted Pixel wrote:
Why would this happen?
An example code that would generate this "anomaly" would be helpful...
Distorted Pixel wrote:
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?
Tripolar, no?

Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Tue Jul 02, 2024 6:35 pm
by netmaestro
The problem as stated cannot be solved. There are just too many reasons this would happen. Try to put together a snippet where it's happening and post that.
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 12:45 am
by Distorted Pixel
:
boddhi Said:
Tripolar no?
I can't say I have heard of that
I have been using IceDesigner for my interface creating. As I said in my first post, If I run just the one window code it works, but running it in the whole program it will not debug the user typed string.
Below isn't the code including the IceDesigner code, but it is doing the same thing even though it is running by itself with no other previous windows as in my program.
[Edit] I just rearranged the drawing code to be more like original code when it comes to the images. (In the original code I actually load an image into an ImageGadget and disable the gadget. It is as big as the main window and redrawn to the ScreenOuput for the WindowedScreen.)
Example code:
Code: Select all
; window 1
EnableExplicit
Global PlayerName.s, return_key_down, String_1
Global Cont_1 = 0
If OpenWindow(0, 0, 0, 600, 250,"ContainerGadget with StringGadget",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
CreateImage(0, 600, 250, 32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(0, 0, 110))
StopDrawing()
ImageGadget(0, 0, 0, 600, 250, ImageID(0))
DisableGadget(0, #True)
InitSprite() : InitKeyboard()
OpenWindowedScreen(WindowID(0), 0, 0, 600, 250, #True, #False, #False)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(0, 0, 110))
StopDrawing()
ContainerGadget(Cont_1, 115, 70, 350, 150, #PB_Container_Raised)
SetGadgetColor(Cont_1,#PB_Gadget_BackColor, RGB(0, 0, 150))
StringGadget(1, 45, 70, 250, 25, "")
SetActiveGadget(1)
CloseGadgetList()
Repeat
ExamineKeyboard()
PlayerName = GetGadgetText(String_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
SetGadgetText(String_1, "")
Break
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 12:57 am
by RASHAD
What is your problem?
Code: Select all
EnableExplicit
Global PlayerName.s, return_key_down, String_1
Global Cont_1 = 0
If OpenWindow(0, 0, 0, 600, 250,"ContainerGadget with StringGadget",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
SetWindowColor(0, RGB(0, 0, 190))
InitSprite() : InitKeyboard()
OpenWindowedScreen(WindowID(0), 0, 0, 600, 250, #True, #False, #False)
CreateImage(0, 600, 250, 32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(10, 10, 110))
StopDrawing()
ImageGadget(0, 0, 0, 600, 250, ImageID(0))
DisableGadget(0, #True)
ContainerGadget(Cont_1, 115, 70, 350, 150, #PB_Container_Raised)
SetGadgetColor(Cont_1,#PB_Gadget_BackColor, RGB(0, 0, 150))
StringGadget(1, 45, 70, 250, 25, "")
SetActiveGadget(1)
CloseGadgetList()
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Return) ;And return_key_down = #False
return_key_down = #True
ElseIf KeyboardReleased(#PB_Key_Return) ;And return_key_down = #True
return_key_down = #False
Debug GetGadgetText(1)
;Break
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 1:06 am
by Distorted Pixel
RASHAD wrote: Wed Jul 03, 2024 12:57 am
What is your problem?
The above code in my first post is just a quick example code that does the same thing as my original code. It won't debug the user typed string to the debug window. The debug opens, but is blank
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 1:11 am
by RASHAD
It seems that Your IF conditions are wrong
No problem getting the text from the string gadget inside a container or no container at all
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 3:12 am
by Distorted Pixel
I have fixed my example code in the first post. I found that I had a "
1" in places that should have been String_1.
Unfortunately, it didn't help with figuring out why my original code is not working with the rest of the program. When I run the whole program, I get to the screen that the user can type in their name and press return key and I type a name and press return key and nothing happens. It doesn't clear what I type or close the window.
IceDesigner uses a fair amount of CompilerIf/EndCompilerIf statements and for me that is more complicated to some degree. I am also trying to use only one main game loop. So far up to this enter player name screen I have succeeded, but this screen is haunting me lol.
Code: Select all
EnableExplicit
Global PlayerName.s, return_key_down
Global Cont_1 = 0
Global String_1 = 1
If OpenWindow(0, 0, 0, 600, 250,"ContainerGadget with StringGadget",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
CreateImage(0, 600, 250, 32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(0, 0, 110))
StopDrawing()
ImageGadget(0, 0, 0, 600, 250, ImageID(0))
DisableGadget(0, #True)
InitSprite() : InitKeyboard()
OpenWindowedScreen(WindowID(0), 0, 0, 600, 250, #True, #False, #False)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(0, 0, 110))
StopDrawing()
ContainerGadget(Cont_1, 115, 70, 350, 150, #PB_Container_Raised)
SetGadgetColor(Cont_1,#PB_Gadget_BackColor, RGB(0, 0, 150))
StringGadget(String_1, 45, 70, 250, 25, "")
SetActiveGadget(String_1)
CloseGadgetList()
Repeat
ExamineKeyboard()
PlayerName = GetGadgetText(String_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
SetGadgetText(String_1, "")
Break
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 5:41 am
by #NULL
You have an ImageGadget 0 and a ContainerGadget Cont_1 which is also 0, so that's a conflict right there. Your StringGadget problem might have a similar reason.
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 6:44 am
by infratec
Works:
Code: Select all
EnableExplicit
Enumeration Gadget
#Img_1
#Cont_1
#String_1
EndEnumeration
Global PlayerName.s, return_key_down
If OpenWindow(0, 0, 0, 600, 250,"ContainerGadget with StringGadget",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
CreateImage(0, 600, 250, 32)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(0, 0, 110))
StopDrawing()
ImageGadget(#Img_1, 0, 0, 600, 250, ImageID(0))
DisableGadget(#Img_1, #True)
InitSprite() : InitKeyboard()
OpenWindowedScreen(WindowID(0), 0, 0, 600, 250, #True, #False, #False)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 600, 250, RGB(0, 0, 110))
StopDrawing()
ContainerGadget(#Cont_1, 115, 70, 350, 150, #PB_Container_Raised)
SetGadgetColor(#Cont_1,#PB_Gadget_BackColor, RGB(0, 0, 150))
StringGadget(#String_1, 45, 70, 250, 25, "")
SetActiveGadget(#String_1)
CloseGadgetList()
Repeat
ExamineKeyboard()
PlayerName = GetGadgetText(#String_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
SetGadgetText(#String_1, "")
Break
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 12:00 pm
by Distorted Pixel
#NULL wrote: Wed Jul 03, 2024 5:41 am
You have an ImageGadget 0 and a ContainerGadget Cont_1 which is also 0, so that's a conflict right there. Your StringGadget problem might have a similar reason.
In my last post with code, I changed certain variable numbers so they would be different and it works.
@infratec
Yes, that code works, and so does the code in my last post with code.
I did forget to mention that in the original code, all gadgets are set with
#PB_Any so they are all different
I will try to put together a new example created with IceDesigner. I will post it when I get it finished.
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 1:44 pm
by blueb
IceDesign offers many ways to do things. Personally I don't like to use '#PB_Any'.
I find it adds a lot of 'fluff', although I have used it in some instances.
I prefer to use the '#Constants' option along with the 'Bind All Gadgets Events' flag, so that my events are isolated to my liking.
Just say'in

Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 4:26 pm
by mk-soft
That's how I see it too.
I also always use constants with named enumeration.
No unnecessary variables, clear assignment.
With my EventDesigner, I can then also call the function for events with a virtual table.
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 6:47 pm
by Distorted Pixel
[/quote]
blueb wrote: Wed Jul 03, 2024 1:44 pm
IceDesign offers many ways to do things. Personally I don't like to use '#PB_Any'.
I find it adds a lot of 'fluff', although I have used it in some instances.
I prefer to use the '#Constants' option along with the 'Bind All Gadgets Events' flag, so that my events are isolated to my liking.
Just say'in
I have to say I agree now, I like the
#Constants because if you use Enumeration/EndEnumeration it numbers them for you.
I can't say I like using
#PB_Any myself either now unless needed for specific situations(what ever they may be lol)
mk-soft wrote: Wed Jul 03, 2024 4:26 pm
That's how I see it too.
I also always use constants with named enumeration.
No unnecessary variables, clear assignment.
With my EventDesigner, I can then also call the function for events with a virtual table.
I have tested your EventDesigner and I like the idea, but it was kind of confusing to me. I don't know if you have updated it since I have tested it so I'd have to take a look at it again.
Below is a
example project only to download. I set it up just like the original project I'm working on, but I used cheesy quick images I created in Gimp for this example. I created it with IceDesigner using
#Constants
I will be removing the link at some point soon. THE DOWNLOAD DOES NOT INCLUDE ICEDESIGNER SOFTWARE just the
test project folder
Run the program and
click the Splash Screen image to continue to the next screen
https://mega.nz/file/E9sXyJKJ#_ZdCjTRIY ... NYiEPzqdIA
Re: Retrieve text from StringGadget that is inside ContainerGadget
Posted: Wed Jul 03, 2024 7:36 pm
by #NULL
Here on linux, normal gadgets mixed with a screen don't work (especially not overlapping). I think the screen continuously steals the focus from the StringGadget.
You also need a Flipbuffers() once per frame I think if you use a screen.
And you need a proper event handling, processing all events once per frame, not just one event per frame.
If all that doesn't apply to Windows (I don't know really) then forget about my post
