Page 1 of 1

How to get text of a string gadget ?

Posted: Thu Aug 09, 2012 2:05 am
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...

Re: How to get text of a string gadget ?

Posted: Thu Aug 09, 2012 2:12 am
by Arctic Fox

Code: Select all

text = GetGadgetText(#String_3)

Re: How to get text of a string gadget ?

Posted: Thu Aug 09, 2012 2:12 am
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 :)

Re: How to get text of a string gadget ?

Posted: Thu Aug 09, 2012 3:55 pm
by Primoz128
Visual coding is fun... though i could use some similar for games -.-