Jump to content
Sign in to follow this  
Gustav Schubert

How to get the selected Font from Picker on Mac

Recommended Posts

On the OSX64 platform I want to use native Pickers for Color (TNsColorPanel) and Font (TNsFontPanel).

 

The idea is that first the dialog must be shown (initialized) so that the user can select a color or font in the dialog.

Then, at any time, if an action is triggered in the App, the currently selected Color or Font should be retrieved and used.

 

It works for Color, but not for Font. I don't implement changeFont since I don't know how. But it looks as if a working handler is needed, or it won't work.

Won't work means that the current Font cannot be retrieved via the convertFont method of the FontManager.

 

https://github.com/federgraph/federgraph-meme-builder/blob/6e035f461e47ed0b30c46ceb36960cbfd528c6c2/MB/RiggVar.MB.Picker.Mac.pas#L104

 

- debug on Mac (F9)


- press button sC (show Color Panel)
- change color in panel

- select App window (focus)
- press button pC (pick Color), ok


- press button sF (show Font Panel)
- chang Font in panel
- ( set breakpoint in TPickerMac.SelectFontFamilyName )

- select App window (focus)
- press button pF (pick Font)

- todo: make it work

 

Should I give up at this point, and if so, why?

Share this post


Link to post

I include a minimal test project for FMX, OSX64 target only, see attachment.

 

( You can change TRectangle.Fill.Color and TText.Font.Family via native dialogs, see screenshot. )

ChangeColorTest.thumb.jpg.d15f98ccddcc47c3fcac216de60d48d4.jpg

This seems to work somehow, but there are at least two remaining problems:
1) Color: If you change from Apple to Developer in combo box and continue to use the dialog - it will crash the App.
2) Font: selectedFont is the value navigated from, not the value navigated to; in the example the font family of the TText should be Arial Narrow, not Arial Black.

 

I would like to understand the reason for problem 1, any idea?

ChangeColorTest.zip

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×