Re: Changing fonts without font menu?
Re: Changing fonts without font menu?
- Subject: Re: Changing fonts without font menu?
- From: Fredrik Olsson <email@hidden>
- Date: Mon, 12 Jun 2006 08:43:56 +0200
Aki Inoue skrev:
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.
Among my own helper code I have an extension to NSObject that implements:
+ (BOOL)instancesCouldConformToProtocol:(Protocol *)aProtocol;
+ (void)setInstancesConformsToProtocol:(Protocol *)aProtocol;
As for example NSButton (and pretty much all other controls as well)
have everything needed to conform to NSValidatedUserInterfaceItem
(action and tag), I simply make the classes conform the the protocol at
start of the app, and use a subclass of NSWindow with a new update that
validates controls on it. Works as a charm, and is consistent with how
menus and toolbar items are validated. In all honesty I never understood
why this is not the default since 10.0 :).
Unfortunately my user base are not that keen on upgrading to the latest
version of OSX, some even still complain that 10.1 is not supported :/.
So well, bindings and all other nice new features are just outside of my
reach right now...
<snip>
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).
So what is the recomended way to programmatically send "make bold",
"increase font size" to a NSTextView (And request current status;
set/unset/mixes would be ice), that is compatible with how the menu
items do it?
Or do any one have code for a sublcass to NSTextView that implements
bold:, italic:, etc, to work consistently with how underline: now works?
// 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