Wow, so uh, I was duplicating a lot of work there. You rock. I don't
know how I managed to miss that.

You don't need to explain, but I am idly wondering why Caret is a
separate class, since text fields can never have more than one. You
may as well have just put in an "editable" flag and some caret-moving
methods. But it's really not important, since I just wrote my own
class that does just that.

While I'm here, I may as well ask another minor question that probably
doesn't warrant its own new thread - is there any way to make the text
classes handle large strings better, or do something better myself? I
just loaded the entire script of _Buckaroo Banzai: Across the 8th
Dimension_ in, and things got really slow, especially text insertion.

I just tried one more thing before submitting this - I was using the
text insertion features of the document class to load a file, but I
just switched to using pyglet.text.load(), and I keep getting the same
error with it:
"TypeError: _uninit_document() takes exactly 1 argument (2 given)
module body       in [my file].py at line 19
function _set_document    in untitled at line 792"

The offending line:
window.text_layout_and_caret_wrapper.my_layout.document =
pyglet.text.load('Buckaroo Banzai.txt')


On Jun 4, 7:05 pm, "Alex Holkner" <[EMAIL PROTECTED]> wrote:
> On 6/5/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> >  I'm trying to write a simple text editor in pyglet as an exercise.
> >  Everything has worked fine so far, including moving the cursor,
> >  inserting/deleting text, etc. However, when I press the Return key, a
> >  space character is passed to on_text(). If I hit Enter, no character
> >  is passed at all.
>
> >  Mac OS X 10.5.2, pyglet 1.1b1
>
> >  My function:
> >  def on_text(self,text):
> >         self.text_area.begin_update()
> >         self.text_area.document.insert_text(self.cursor,text)
> >         self.cursor += len(text)
> >         self.text_area.end_update()
>
> Try the examples/events.py program, to make sure you're not just
> misprinting the '\r' character that's generated.  You'll need to
> convert this '\r' into a '\n' for display in a multiline TextLayout.
>
> (Just in case you're unaware, the Caret class provides all of this
> functionality).
>
> Alex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to