Format General UI Controls For Platform
I created this To-Do application on a Mac. That means that if I set the text size or style of any controls that the current font was saved with the control. In this case Lucida Grande. The stack won't look very nice on Windows so we are going to look at an easy way to format controls to use the right font on each platform.
What the Program Looks Like On Windows
If you were to open the To-Do application on Windows it would look like this. Notice that the + sign in the buttons is very small. This is because I assigned some text attributes to the graphics using the Object Inspector while working in the IDE. This saved Lucida Grande as the textFont of the graphics. Since Lucida Grande isn't included on Windows Revolution can't display the text properly.
Browse libControlFormatter Script
Edit the script of the libControlFormatter stack.
The FormatCardControlsForPlatform Command
The FormatCardControlsForPlatform command is a handy command that resets the text font for controls on your card. For some controls it also updates margins and resizes fields to fit the text. Let's look at how to use this in the To-Do application.
Edit Card Script
Edit the main program window card script again.
Update PreOpenView Script
Replace PreOpenView with the following RevTalk code:
on PreOpenView pHasBeenOpened
## EQUIVALENT TO preOpenCard BUT WITH A PARAMETER LETTING YOU KNOW
## IF THIS CARD HAS BEEN OPENED DURING THE APPLICATION SESSION.
if not pHasBeenOpened then
## initialize fonts, button sizes, etc.
put the long id of stack "Data Grid Templates 1253718463648" into theStack
dispatch "FormatCardControlsForPlatform" to card "ProjectsPeople" of theStack
dispatch "FormatCardControlsForPlatform" to card "To-Do" of theStack
if the platform is "macos" then
set the dgProps["scrollbar corner offset"] of group "ToDo" to 15
set the dgProps["scrollbar corner offset"] of group "ToDo" to 0
When the card opens for the first time in a session FormatCardControlsForPlatform is called. This resets the textFont for all the appropriate controls on the card (1).
The FormatCardControlsForPlatform command is also sent to the cards of the Data Grid stack so that their control fonts can be reset (2).
With the addition of these handlers the "+" buttons now look correct on Windows.