How to get text of a string gadget ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Primoz128
Enthusiast
Enthusiast
Posts: 212
Joined: Sat Sep 10, 2011 8:25 pm
Location: Slovenia

How to get text of a string gadget ?

Post by Primoz128 »

Code: Select all

;{- Enumerations / DataSections
;{ Windows
Enumeration
  #Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
  #Button_0
  #String_3
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 429, 250, 400, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    ButtonGadget(#Button_0, 85, 255, 225, 70, "Gadget_0")
    text.s = StringGadget(#String_3, 75, 55, 230, 80, "Gadget_3")
  EndIf
EndProcedure

OpenWindow_Window_0()

;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #Button_0
      ElseIf EventGadget = #String_3
         OpenConsole()
         PrintN(text)
         Delay(2000)
      EndIf
    ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #Window_0
        CloseWindow(#Window_0)
        Break
      EndIf
  EndSelect
ForEver
;
;}
I don't know really...
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: How to get text of a string gadget ?

Post by Arctic Fox »

Code: Select all

text = GetGadgetText(#String_3)
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: How to get text of a string gadget ?

Post by Paul »

If you look in the help file under "StringGadget", you will see how to create a String Gadget (proper Syntax) as well as various commands that can be used with this gadget...

If you look further down in that section under "Also see"
GetGadgetText(), SetGadgetText(), GetGadgetColor(), SetGadgetColor()


Help File is your friend :)
Image Image
User avatar
Primoz128
Enthusiast
Enthusiast
Posts: 212
Joined: Sat Sep 10, 2011 8:25 pm
Location: Slovenia

Re: How to get text of a string gadget ?

Post by Primoz128 »

Visual coding is fun... though i could use some similar for games -.-
Post Reply