Text Gadget and no variable

You need some new stunning features ? Tell us here.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Text Gadget and no variable

Post by falsam »

Hello Polo.

Actualy, a variable is associated with a textgadget. If I remove this variable in the gadget inspector, I have this form.

Code: Select all

Procedure OpenMainForm(x = 0, y = 0, width = 600, height = 400)
  OpenWindow(#MainForm, x, y, width, height, "", #PB_Window_SystemMenu)
   = TextGadget(#PB_Any, 40, 50, 100, 25, "My TextGadget")
EndProcedure
Is it possible to create a textgadget (or combogadget) without variable?

Thank.

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

Re: Text Gadget and no variable

Post by mhs »

Every Gadget in PB needs an ID. The Visual Designer offers two ways (the same like manual coding...) for that:
  • Constants
  • #PB_Any in combination with variables
Uncheck the Checkbox "#PB_Any" in the Gadget properties an set a name for the constant and all is fine.

Code: Select all

Enumeration FormWindow
  #MainForm
EndEnumeration

Enumeration FormGadget
  #txt
EndEnumeration


Procedure OpenMainForm(x = 0, y = 0, width = 600, height = 400)
  OpenWindow(#MainForm, x, y, width, height, "", #PB_Window_SystemMenu)
  TextGadget(#txt, 40, 50, 100, 25, "My TextGadget")
EndProcedure
You can change this behaviour as default also in the options.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Text Gadget and no variable

Post by falsam »

Hello mhs.

Forgive me, but why use a variable that has no use?

I have a preference for this code.

Code: Select all

Enumeration FormWindow
  #MainForm
EndEnumeration

Procedure OpenMainForm(x = 0, y = 0, width = 600, height = 400)
  OpenWindow(#MainForm, x, y, width, height, "", #PB_Window_SystemMenu)
  TextGadget(#PB_Any, 40, 50, 100, 25, "My TextGadget")
EndProcedure
It is functional :wink:

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

Re: Text Gadget and no variable

Post by mhs »

falsam wrote:Forgive me, but why use a variable that has no use?
If you uncheck the option #PB_Any then no variable is used for that gadget.

Instead, a constant is used, which has no consequences on memory, performance or something like that. It's just a number and don't hurts.
Somewhere the visual designer must have its limitations, he can not please everyone.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Text Gadget and no variable

Post by Polo »

I can see why in some situation keeping the pointer is not necessary, although the form designer is made to keep track of each gadget's id or pointer so I'm afraid it will remain as it is.
Post Reply