Found an issue in SpiderBasic ? Please report it here !
DanLJr
 
Posts: 13
Joined: Wed Jul 04, 2018 4:24 am

ResizeGadget Doesn't Respect #PB_Ignore

by DanLJr Fri Jul 06, 2018 5:45 pm

Line 12: ResizeGadget(TxtGadID, TxtGadX, TxtGadY, #PB_Ignore, #PB_Ignore) seems to be the problem:

Code: Select all
Global g_CurrentWindow
Global g_HiWrld$ = "Hello World!"

Procedure RecenterControls(WindowID)
 
  Static TxtGadID
 
  If WindowID
    TxtGadX = (WindowWidth(WindowID)-300)/2
    TxtGadY = (WindowHeight(WindowID)-300)/2
    If TxtGadID
      ResizeGadget(TxtGadID, TxtGadX, TxtGadY, #PB_Ignore, #PB_Ignore)
    Else
      TxtGadID = TextGadget(#PB_Any, TxtGadX, TxtGadY, 300, 300, g_HiWrld$, #PB_Text_Center + #PB_Text_VerticalCenter + #PB_Text_Border)
    EndIf
  EndIf
 
  Debug "Window ID:" + Str(WindowID)
  Debug "Window Size: " + Str(WindowHeight(WindowID)) + " " + Str(WindowWidth(WindowID))
  Debug "TextGadget ID:" + Str(TxtGadID)
  Debug "Set TextGadget Position To: " + Str(TxtGadX) + " " + Str(TxtGadY)
  Debug "Reported Position: "+ Str(GadgetX(TxtGadID)) + " " + Str(GadgetY(TxtGadID))

EndProcedure

Procedure Event_WindowResized()
  Debug "Resize Event Triggered!"
  RecenterControls(g_CurrentWindow)
EndProcedure

Procedure Main()

  g_CurrentWindow = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore, g_HiWrld$, #PB_Window_Background)
  RecenterControls(g_CurrentWindow)
 
  BindEvent(#PB_Event_SizeWindow, @Event_WindowResized())
 
EndProcedure

Main()


If I change:

Code: Select all
ResizeGadget(TxtGadID, TxtGadX, TxtGadY, #PB_Ignore, #PB_Ignore)


To:

Code: Select all
ResizeGadget(TxtGadID, TxtGadX, TxtGadY, 300, 300)


then everything works. Why is SB "ignoring" the #PB_Ignore constants for Height and Width, and instead it's doing some crazy/weird arbitrary shrinking with every resize!!!??? (It even discusses the use of #PB_Ignore in the context of Resize explicitly in the docs with a sample!)

Am I just doing something wrong here, or is this a pretty obvious/big bug? (I'm new to SB, so sorry if this is NOT a bug and I'm just being think-headed...)

Thanks in advance,
-Dan
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 0 guests