Hello!
Imagine that I have a string, for example: "Filename:N/A".
I want to create a TextGadget with it, but with the exact size of the text above.
I tried:
TextWidth("Filename:N/A")
but I got an error as it seems to work only with drawing text
Is there a way to make it work with normal gadgets?
Thank you!
Kind regards,
>Marco A.G.Pinto
---------------
TextWidth in TextGadget
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: TextWidth in TextGadget
GadgetWidth() with the mode set to #PB_Gadget_RequiredSize should give you what you are after.
I may look like a mule, but I'm not a complete ass.
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: TextWidth in TextGadget
Thank you for your suggestion, but it doesn't work:srod wrote:GadgetWidth() with the mode set to #PB_Gadget_RequiredSize should give you what you are after.
Code: Select all
TextGadget(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS,10,y,200+10,16,"# Words:"+Str(number_of_words))
ResizeGadget(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS,GadgetX(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS),GadgetY(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS),GadgetWidth(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS),#PB_Gadget_RequiredSize)
TextGadget(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS_ASTERISK,GadgetX(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS)+GadgetWidth(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS),y,16,16,"*")
SetGadgetColor(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS_ASTERISK,#PB_Gadget_FrontColor,#Red)
Could you help?
Thank you!
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: TextWidth in TextGadget
ahhhh... it is working... sorry.
Thank you again!
Thank you again!
Re: TextWidth in TextGadget
You have put the constant as a parameter to ResizeGadget() instead of GadgetWidth().
Re: TextWidth in TextGadget
With variable names that long, I wonder how you can see anything?
(I hope it's just for the example?)
For the compiler, spaces don't count, add spaces and split, split, split lines ( , + - )
The indentation is automatic and will tell you if you cut in the right placeIt's easier to see if you've forgotten a parameter, or put it in the wrong place
(I hope it's just for the example?)
For the compiler, spaces don't count, add spaces and split, split, split lines ( , + - )
The indentation is automatic and will tell you if you cut in the right place
Code: Select all
TextGadget(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS_ASTERISK,
GadgetX(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS) +
GadgetWidth(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS, #PB_Gadget_RequiredSize),
y, 16, 16, "*")
- marcoagpinto
- Addict
- Posts: 947
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: TextWidth in TextGadget
Buaaaaaaaaaaa... lately I have been using variables bigger and bigger to make it easier to remember what they are for.Marc56us wrote:With variable names that long, I wonder how you can see anything?
(I hope it's just for the example?)
For the compiler, spaces don't count, add spaces and split, split, split lines ( , + - )
The indentation is automatic and will tell you if you cut in the right placeIt's easier to see if you've forgotten a parameter, or put it in the wrong placeCode: Select all
TextGadget(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS_ASTERISK, GadgetX(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS) + GadgetWidth(#TEXT_PANEL_BOX_DICTIONARY_NUMBER_WORDS, #PB_Gadget_RequiredSize), y, 16, 16, "*")
Thank you guys for all the suggestions.