At Wed, 01 Feb 2012 11:04:36 +0100, Marijn wrote: > On 30-01-12 19:08, Matthew Flatt wrote: > > A note on alignment: > > > > The `text%' class supports 'right and 'center paragraph alignment, > > which more or less works when the editor has a maximum width. (The > > docs have some caveats.) > > > > So, you can get right-alignment to a useful degree with a sequence > > like this: > > > > (define tf (new text-field% ....)) > > > > ;; Make the editor have a maximum width: (send (send tf get-editor) > > auto-wrap #t) ;; Keep the caret visible: (send (send tf get-editor) > > set-padding 0 0 2 0) ;; Right-align the first paragraph: (send > > (send tf get-editor) set-paragraph-alignment 0 'right) > > > > I noticed that refresh wasn't right when editing right-aligned > > text, though, and I pushed a fix for that. > > Thanks Matthew, that seems to work well enough; at least when some > more bugs are squished. It seems that alignment goes back to > left-aligned under certain edits. For example if I have a text-field > with an initial value of 0 and replace that 0 by anything else it gets > left-aligned.
Yes --- effects like that are why the `set-paragraph-alignment' method is still labeled "experimental". I'm not sure how difficult it would be to make paragraph alignment work better, but a possible workaround is to reset the alignment after every change to the text field. ____________________ Racket Users list: http://lists.racket-lang.org/users

