Page 1 of 1

Small example of StringGadget updating TextGadget?

Posted: Thu Mar 06, 2025 11:14 pm
by matalog
I am trying to write a little Android program that converts numbers or something small to start with.

I am struggling to get Gadgets to continuously update like I would in PureBasic with:

Code: Select all

Repeat 
  Event = WaitWindowEvent()

  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
      ;  do various things

    EndSelect
EndSelect

Until Event = #PB_Event_CloseWindow
I can get gadgets to appear, but they don't respond when I click on them or type in something, the way I expected after using PureBasic.

Does anyone have a small example of a StringGadget writing to a TextGadget when the StringGadget is updated?

Re: Small example of StringGadget updating TextGadget?

Posted: Fri Mar 07, 2025 7:28 am
by Peter
In SpiderBasic there is no event loop (WaitWindowEvent()). You have to query the events using Bind*Event().

Code: Select all

EnableExplicit

Enumeration
  #Window
  #TextGadget
  #StringGadget
EndEnumeration

Procedure StringGadgetEvent()
  
  SetGadgetText(#TextGadget, GetGadgetText(#StringGadget))
  
EndProcedure

OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 300, 100, "", #PB_Window_ScreenCentered)
TextGadget(#TextGadget, 10, 10, 200, 30, "", #PB_Text_Border)
StringGadget(#StringGadget, 10, 50, 200, 30, "")

BindGadgetEvent(#StringGadget, @StringGadgetEvent())

SetActiveGadget(#StringGadget)
Image

Re: Small example of StringGadget updating TextGadget?

Posted: Fri Mar 07, 2025 9:41 pm
by matalog
Peter wrote: Fri Mar 07, 2025 7:28 am In SpiderBasic there is no event loop (WaitWindowEvent()). You have to query the events using Bind*Event().

Code: Select all

EnableExplicit

Enumeration
  #Window
  #TextGadget
  #StringGadget
EndEnumeration

Procedure StringGadgetEvent()
  
  SetGadgetText(#TextGadget, GetGadgetText(#StringGadget))
  
EndProcedure

OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 300, 100, "", #PB_Window_ScreenCentered)
TextGadget(#TextGadget, 10, 10, 200, 30, "", #PB_Text_Border)
StringGadget(#StringGadget, 10, 50, 200, 30, "")

BindGadgetEvent(#StringGadget, @StringGadgetEvent())

SetActiveGadget(#StringGadget)
Image
Thanks Peter, I have got that working now, and understand a little bit more.