I see that by default, there’s a few App constants defined (when building a desktop App) like kEditClear, kFileQuit, kFileQuitShortCut which are different depending on the platform…
What’s the purpose of the # in front of these constants in the IDE? (I’ve done some searching but cannot find the answer) I assume it’s to differentiate between literal and constant (kinda like a macro)?
Where else can the # be used in Xojo? Is there documentation on the use of the #?
That being said… I don’t see a “#” in those constants… I DO see a “&” , which indicates the letter should be underlined when shown in a menu (just like VB did)
No worries… I don’t think you need to worry about any use of # except for the two instances in my first post
I’ve been using Xojo since 2006 and never have
Although I use this feature quite a bit, I only just recently came across where it is documented the other day, on the page about the IDE Inspector, under the “Constants” section it says:
"To use a constant for a property value, precede its name with "#" (pound sign). For example, if you want to use a global constant (in a module) named AcceptButtonText, you would refer to it in the Caption property of a button as "#AcceptButtonText".
Oh, and I just remembered a blog post from a while ago that shows a simple example of using the # syntax for Dynamic Constants, when you want to implement language localization for an app.
Basically, once you enter the # reference to a constant in the Menu Editor or the Control Inspector for the UI readable text of a menu or control, the dynamic part of the Constant automatically changes what language entry you associated with that constant, when the user is running your app like in a French version of macOS or Windows. So, one # entry = potentially many different outputs. Very handy.
[quote=468827:@Andy Broughton]
Where else can the # be used in Xojo? Is there documentation on the use of the #?[/quote]
right click a color and you can assign a color constant
right click a boolean constant and you can assign a boolean constant
most places you can enter text or numbers you can put in a #Constant
[quote=468847:@Norman Palardy]right click a color and you can assign a color constant
right click a boolean constant and you can assign a boolean constant
most places you can enter text or numbers you can put in a #Constant[/quote]
Except where I wanted to use it of course - in the menuitem’s icon property. (It’s a popup rather than a textfield)
Just tested this, I see what you’re saying about color and boolean properties, but I cannot seem to do this with a text field. I get the Mac default context menu (Look Up, Search with Google, etc.)
[quote=468843:@Scott Cadillac]Although I use this feature quite a bit, I only just recently came across where it is documented the other day, on the page about the IDE Inspector, under the “Constants” section it says:
"To use a constant for a property value, precede its name with "#" (pound sign). For example, if you want to use a global constant (in a module) named AcceptButtonText, you would refer to it in the Caption property of a button as "#AcceptButtonText".
Good find. I searched quite a bit and never found that one!
If you add images to your project using the Image Set Editor, the image name you give becomes a global variable name and then appears in the Icon drop-down for you to select for your menu item.
Although I use Image Sets in other parts of my projects, I haven’t tried this with a menu item yet, but I’m guessing you start with a 16px by 16px image, then 32x32 for a Retina version of the same image. Xojo will take care of deciding which size image to assign, based on the screen resolution of the user.
[quote=468891:@Scott Cadillac]If you add images to your project using the Image Set Editor, the image name you give becomes a global variable name and then appears in the Icon drop-down for you to select for your menu item.
Although I use Image Sets in other parts of my projects, I haven’t tried this with a menu item yet, but I’m guessing you start with a 16px by 16px image, then 32x32 for a Retina version of the same image. Xojo will take care of deciding which size image to assign, based on the screen resolution of the user.
I hope that helps.[/quote]
Thanks, Scott. That’s most likely the answer to the other thread I started regarding menu item icons.
However, it doesn’t help with the per-platform/language constants for icons. Seems like an oversight - they could have allowed a constant for the icon property, but don’t. Funny, since by default they use that very feature for the text property!