Re: NSTextView shared state magic?
Re: NSTextView shared state magic?
- Subject: Re: NSTextView shared state magic?
- From: Keith Blount <email@hidden>
- Date: Mon, 11 Feb 2008 10:06:38 -0800 (PST)
Many thanks for the reply. I took a look at the GNUStep implementation of NSTextView and saw that they had internal methods for this too, so I did something similar. In the end, I added my text view as an observer for the key paths of its own custom methods, and whenever one changes it changes them for all other text views associated with the layout manager, too. I have to do this manually when new pages get added, so it would probably be best to do this via a layout manager as you suggest, which could observe for these changes instead and sync things whenever a new text container is added, but for now it works.
Thanks again!
All the best,
Keith
----- Original Message ----
From: Douglas Davidson <email@hidden>
To: Keith Blount <email@hidden>
Cc: email@hidden
Sent: Monday, February 11, 2008 4:37:28 AM
Subject: Re: NSTextView shared state magic?
On
Feb
9,
2008,
at
8:23
AM,
Keith
Blount
wrote:
>
I'm
in
the
process
of
putting
together
a
"page
layout"
view
for
my
>
app,
much
like
the
"Wrap
to
Page"
mode
in
TextEdit.
So
far,
so
good.
>
However,
I
have
a
heavily
subclassed
NSTextView
which
has
certain
>
extra
features
-
coloured
annotations,
highlight
colours
and
so
>
forth.
When
a
layout
manager
has
several
text
containers
each
with
>
an
associated
text
view,
there
are
certain
attributes
that
are
>
shared
across
all
of
those
text
views
-
whether
they
use
the
font
>
panel,
have
spell-checking
enabled
and
so
forth.
Is
there
any
way
to
>
tell
a
text
view
that
it
should
share
other,
custom,
attributes,
>
too?
For
instance,
if
someone
creates
an
annotation
in
my
text
view,
>
they
can
set
its
colour.
In
doing
so,
my
text
view
receives
a
-
>
setAnnotationColor:
message
so
that
when
the
user
creates
another
>
annotation,
it
will
assume
the
colour
they
last
used.
When
I
have
>
multiple
text
views,
however,
only
the
current
text
view
receives
>
this
message,
so
that
if
the
user
creates
>
an
annotation
on
another
"page",
it
uses
the
colour
last
used
on
>
that
page
rather
than
the
colour
last
used
in
the
document.
>
>
>
What's
the
best
way
of
getting
other
text
views
that
use
the
same
>
layout
manager
to
share
custom
attributes
as
set
in
the
-
>
firstTextView?
(Or
do
I
have
to
do
it
all
manually?)
Internally
NSTextView
has
a
private
shared-state
object,
and
a
bit
of
mechanism
for
making
sure
that
it
is
properly
maintained
as
text
views
come
and
go.
We
don't
really
expose
that
to
clients
and
subclasses,
so
for
your
own
custom
state
you
would
have
to
do
something
similar
yourself.
It
shouldn't
be
too
difficult.
Depending
on
how
you
are
using
the
text
system,
one
option
would
be
to
actually
maintain
your
custom
shared
state
in
the
layout
manager,
using
a
custom
NSLayoutManager
subclass,
and
have
all
of
the
text
view
methods
involved
call
down
to
the
layout
manager
to
set
and
get
their
shared
state.
Douglas
Davidson
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden