Re: Changing fonts without font menu?
Re: Changing fonts without font menu?
- Subject: Re: Changing fonts without font menu?
- From: Aki Inoue <email@hidden>
- Date: Fri, 9 Jun 2006 11:58:11 -0700
I tried it with a "Cocoa Application", and then it kind of semi-
works with a single nib-file. Only problem is that my connected
NSButton can not "unbold" as the menu does (And no selected state as
the menus).
Since the auto validation is currently implemented as -
validateMenuItem:, it only works with NSMenuItems in Tiger. I'm
planning to move the core logic to -validateUserInterfaceItem: in a
future release, then, at least, enable/disable part of the validation
should work with NSToolbarItems.
We don't have a generic way of triggering auto validation for
arbitrary objects (of course, I mean, outside of Cocoa Binding), so
your NSButtonCells need a bit more manually hook ups.
And when having a document based app, with the menu in another nib
than the NSButton hooked up to NSFontManager, it does not work at
all :/
You can hook up your taget, action, and tag manually in your -
[NSDocument windowControllerDidLoadNib:].
My ugly solution is to extend NSTextField, add bold:, italic:
methods, and let them send key events. Very awkward.
My ugly solutions have two major flaws:
1. It makes the Format manu flicker when I click the buttons.
2. I can not think of a clean way to send Cmd-+ and Cmd--.
In addition to the flaws, you're vulnerable if the user changes the
key equivalent for these cmds (they are customizable via System
Prefs). We normally don't recommend trying to control Cocoa UI
objects by synthesizing event objects (including CG, Carbon, NS events).
Aki
Fredrik Olsson skrev:
Aki Inoue skrev:
Frederick,
What I want to do is to let a NSButton wotk the same way as for
example
the "Bold"-menu item that is "provided for free" with the Format-
menu,
or the Font-menu.
I just tried in IB hooking up a button sending -addFontTraits: to
NSFontManager, and it works expectedly.
Note the button tag needs to be set to 2 the bold font trait.
Aki
I tried it with a "Cocoa Application", and then it kind of semi-
works with a single nib-file. Only problem is that my connected
NSButton can not "unbold" as the menu does (And no selected state
as the menus).
And when having a document based app, with the menu in another nib
than the NSButton hooked up to NSFontManager, it does not work at
all :/
My ugly solution is to extend NSTextField, add bold:, italic:
methods, and let them send key events. Very awkward.
My ugly solutions have two major flaws:
1. It makes the Format manu flicker when I click the buttons.
2. I can not think of a clean way to send Cmd-+ and Cmd--.
Help! :)
// Fredrik Olsson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden