Page 1 of 1

Text Gadget and no variable

Posted: Wed Mar 02, 2016 11:08 am
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.

Re: Text Gadget and no variable

Posted: Wed Mar 02, 2016 11:33 am
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.

Re: Text Gadget and no variable

Posted: Wed Mar 02, 2016 3:36 pm
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:

Re: Text Gadget and no variable

Posted: Wed Mar 02, 2016 3:52 pm
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.

Re: Text Gadget and no variable

Posted: Fri Mar 25, 2016 1:35 pm
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.